Add example for finding ok button.
This commit is contained in:
parent
30be2575d1
commit
7bc352bffd
|
@ -0,0 +1,23 @@
|
|||
package org.assertj.swing.aut.lookup;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
import net.miginfocom.layout.AC;
|
||||
import net.miginfocom.layout.LC;
|
||||
|
||||
import org.assertj.swing.aut.components.SampleFrame;
|
||||
|
||||
public class SimpleFrame extends SampleFrame {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public SimpleFrame() {
|
||||
setMiglayout(new LC().wrapAfter(1), new AC().align("center"), new AC());
|
||||
|
||||
JButton okButton = new JButton("OK");
|
||||
okButton.setName("ok");
|
||||
|
||||
add(okButton);
|
||||
|
||||
pack();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.assertj.swing.junit.examples.lookup;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
import org.assertj.swing.aut.lookup.SimpleFrame;
|
||||
import org.assertj.swing.core.GenericTypeMatcher;
|
||||
import org.assertj.swing.edt.GuiActionRunner;
|
||||
import org.assertj.swing.edt.GuiQuery;
|
||||
import org.assertj.swing.fixture.FrameFixture;
|
||||
import org.assertj.swing.junit.SwingJUnitExamples;
|
||||
import org.junit.Test;
|
||||
|
||||
public class SimpleFrame_GenericTypeMatcher_Test extends SwingJUnitExamples {
|
||||
private FrameFixture window;
|
||||
|
||||
@Override
|
||||
protected void onSetUp() {
|
||||
SimpleFrame frame = GuiActionRunner.execute(new GuiQuery<SimpleFrame>() {
|
||||
protected SimpleFrame executeInEDT() {
|
||||
return new SimpleFrame();
|
||||
}
|
||||
});
|
||||
window = new FrameFixture(robot(), frame);
|
||||
window.show();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shoulFindOkButton() {
|
||||
GenericTypeMatcher<JButton> textMatcher = new GenericTypeMatcher<JButton>(JButton.class) {
|
||||
@Override
|
||||
protected boolean isMatching(JButton button) {
|
||||
return "OK".equals(button.getText());
|
||||
}
|
||||
};
|
||||
window.button(textMatcher).requireVisible();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
package org.assertj.swing.testng.examples.lookup;
|
||||
|
||||
import javax.swing.JButton;
|
||||
|
||||
import org.assertj.swing.aut.lookup.SimpleFrame;
|
||||
import org.assertj.swing.core.GenericTypeMatcher;
|
||||
import org.assertj.swing.edt.GuiActionRunner;
|
||||
import org.assertj.swing.edt.GuiQuery;
|
||||
import org.assertj.swing.fixture.FrameFixture;
|
||||
import org.assertj.swing.testng.SwingTestNGExamples;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
public class SimpleFrame_GenericTypeMatcher_Test extends SwingTestNGExamples {
|
||||
private FrameFixture window;
|
||||
|
||||
@Override
|
||||
protected void onSetUp() {
|
||||
SimpleFrame frame = GuiActionRunner.execute(new GuiQuery<SimpleFrame>() {
|
||||
protected SimpleFrame executeInEDT() {
|
||||
return new SimpleFrame();
|
||||
}
|
||||
});
|
||||
window = new FrameFixture(robot(), frame);
|
||||
window.show();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void shoulFindOkButton() {
|
||||
GenericTypeMatcher<JButton> textMatcher = new GenericTypeMatcher<JButton>(JButton.class) {
|
||||
@Override
|
||||
protected boolean isMatching(JButton button) {
|
||||
return "OK".equals(button.getText());
|
||||
}
|
||||
};
|
||||
window.button(textMatcher).requireVisible();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue