use of org.fest.swing.fixture.JButtonFixture in project ats-framework by Axway.
the class SwingButton method click.
/**
* Click button
* @throws VerificationException if the element doesn't exist
*/
@Override
@PublicAtsApi
public void click() {
new SwingElementState(this).waitToBecomeExisting();
((JButtonFixture) SwingElementLocator.findFixture(this)).click();
}
use of org.fest.swing.fixture.JButtonFixture in project intellij-community by JetBrains.
the class ComboBoxActionFixture method click.
private void click() {
final JButtonFixture comboBoxButtonFixture = new JButtonFixture(myRobot, myTarget);
Pause.pause(new Condition("Wait until comboBoxButton is enabled") {
@Override
public boolean test() {
//noinspection ConstantConditions
return execute(new GuiQuery<Boolean>() {
@Override
protected Boolean executeInEDT() throws Throwable {
return comboBoxButtonFixture.target().isEnabled();
}
});
}
}, GuiTestUtil.SHORT_TIMEOUT);
comboBoxButtonFixture.click();
}
use of org.fest.swing.fixture.JButtonFixture in project android by JetBrains.
the class ConvertToConstraintLayoutTest method testConvert2.
@Ignore("http://b.android.com/211200")
@Test
public void testConvert2() throws Exception {
guiTest.importSimpleApplication();
EditorFixture editor = guiTest.ideFrame().getEditor();
editor.open("app/src/main/res/layout/frames.xml", EditorFixture.Tab.DESIGN);
NlEditorFixture layout = editor.getLayoutEditor(false);
layout.waitForRenderToFinish();
// Find and click the first text View
NlComponentFixture button = layout.findView("TextView", 0);
button.invokeContextMenuAction("Convert LinearLayout to ConstraintLayout");
// Confirm dialog
DialogFixture quickFixDialog = WindowFinder.findDialog(Matchers.byTitle(Dialog.class, "Convert to ConstraintLayout")).withTimeout(TimeUnit.MINUTES.toMillis(2)).using(guiTest.robot());
// Press OK
JButtonFixture finish = quickFixDialog.button(withText("OK"));
finish.click();
// Check that we've converted to what we expected
layout.waitForRenderToFinish();
editor.selectEditorTab(EditorFixture.Tab.EDITOR);
waitForScout();
editor.invokeAction(EditorFixture.EditorAction.FORMAT);
@Language("XML") String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<android.support.constraint.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n" + " xmlns:tools=\"http://schemas.android.com/tools\"\n" + " android:id=\"@+id/constraintLayout\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:orientation=\"vertical\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\">\n" + "\n" + " <TextView\n" + " android:id=\"@+id/title\"\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:text=\"Welcome\"\n" + " app:layout_constraintBottom_toBottomOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintRight_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintTop_toBottomOf=\"@+id/constraintLayout\"\n" + " tools:layout_constraintBottom_creator=\"1\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_constraintRight_creator=\"1\"\n" + " tools:layout_constraintTop_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " <FrameLayout\n" + " android:id=\"@+id/attending_remotely\"\n" + " android:layout_width=\"0dp\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:foreground=\"?android:selectableItemBackground\"\n" + " app:layout_constraintBottom_toBottomOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintRight_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintTop_toBottomOf=\"@+id/constraintLayout\"\n" + " tools:layout_constraintBottom_creator=\"1\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_constraintRight_creator=\"1\"\n" + " tools:layout_constraintTop_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\">\n" + "\n" + " <ImageView\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"100dp\"\n" + " android:adjustViewBounds=\"true\"\n" + " android:scaleType=\"centerInside\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/attending_remotely\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " <TextView\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:layout_gravity=\"bottom|end|right\"\n" + " android:text=\"Remotely\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " </FrameLayout>\n" + "\n" + " <FrameLayout\n" + " android:id=\"@+id/attending_in_person\"\n" + " android:layout_width=\"0dp\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:foreground=\"?android:selectableItemBackground\"\n" + " app:layout_constraintBottom_toBottomOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintRight_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintTop_toBottomOf=\"@+id/constraintLayout\"\n" + " tools:layout_constraintBottom_creator=\"1\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_constraintRight_creator=\"1\"\n" + " tools:layout_constraintTop_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\">\n" + "\n" + " <ImageView\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"100dp\"\n" + " android:adjustViewBounds=\"true\"\n" + " android:scaleType=\"centerInside\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/attending_in_person\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " <TextView\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:layout_gravity=\"bottom|end|right\"\n" + " android:text=\"In Person\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " </FrameLayout>\n" + "\n" + "</android.support.constraint.ConstraintLayout>\n";
assertThat(wipeDimensions(editor.getCurrentFileContents())).isEqualTo(wipeDimensions(xml));
}
use of org.fest.swing.fixture.JButtonFixture in project android by JetBrains.
the class NewComponentTest method testNewValueWizard.
@Test
public void testNewValueWizard() throws IOException {
guiTest.importSimpleApplication();
guiTest.ideFrame().getProjectView().selectAndroidPane();
guiTest.ideFrame().invokeMenuPath("File", "New", "XML", "Values XML File");
final NewXmlValueWizardFixture wizardFixture = NewXmlValueWizardFixture.find(guiTest.robot());
final JButtonFixture finishFixture = wizardFixture.findWizardButton("Finish");
finishFixture.requireEnabled();
wizardFixture.getFileNameField().enterText("strings");
final JLabelFixture errorLabel = wizardFixture.findLabel("Values File Name must be unique");
Wait.seconds(1).expecting("Finish to be disabled").until(() -> !finishFixture.isEnabled());
wizardFixture.getFileNameField().enterText("2");
Wait.seconds(1).expecting("Finish to be enabled").until(finishFixture::isEnabled);
// Now test an invalid file name. Currently we have "strings2" so add an space to make it invalid.
wizardFixture.getFileNameField().enterText(" ");
Wait.seconds(1).expecting("Finish to be disabled").until(() -> !finishFixture.isEnabled());
errorLabel.requireText("Values File Name is not set to a valid resource name: ' ' is not a valid resource name character");
// UI tests should close all dialogs before finishing
wizardFixture.findWizardButton("Cancel").click();
}
use of org.fest.swing.fixture.JButtonFixture 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);
}
}
Aggregations