use of junit.extensions.jfcunit.finder.ComponentFinder in project ACS by ACS-Community.
the class AddToDeployTreeTest method testPortValidation.
public void testPortValidation() throws Exception {
JDialog dialog;
AbstractButtonFinder buttonFinder = new AbstractButtonFinder("Add to View");
// { m_ignoreVisiblity || comp.isShowing() }
buttonFinder.setIgnoreVisibility(true);
JButton addButton = (JButton) buttonFinder.find(panel, 0);
assertNotNull("Could not find the Add button", addButton);
buttonFinder.setText("Full Refresh");
JButton refreshButton = (JButton) buttonFinder.find(panel, 0);
assertNotNull("Could not find the Refresh button", refreshButton);
ComponentFinder componentFinder = new ComponentFinder(JTextField.class);
// { m_ignoreVisiblity || comp.isShowing() }
componentFinder.setIgnoreVisibility(true);
JTextField hostField = (JTextField) componentFinder.find(panel, 0);
assertNotNull("Could not find the host field", hostField);
assertEquals("host field is empty", "", hostField.getText());
JTextField portField = (JTextField) componentFinder.find(panel, 0);
assertNotNull("Could not find the port field", portField);
assertEquals("port field is empty", "", portField.getText());
getHelper().sendString(new StringEventData(this, hostField, "testhost"));
getHelper().sendString(new StringEventData(this, portField, "2"));
getHelper().enterClickAndLeave(new MouseEventData(this, addButton));
DialogFinder dFinder = new DialogFinder(null);
dFinder.setWait(2);
List<Object> showingDialogs = dFinder.findAll();
assertEquals("Number of dialogs showing is wrong", 1, showingDialogs.size());
dialog = (JDialog) showingDialogs.get(0);
assertEquals("Wrong dialog showing up", "Message", dialog.getTitle());
TestHelper.disposeWindow(dialog, this);
}
use of junit.extensions.jfcunit.finder.ComponentFinder in project JMRI by JMRI.
the class NXFrameTest method getRadioButtons.
// For types from DialogFinder().findAll(..)
@SuppressWarnings("unchecked")
private static List<JRadioButton> getRadioButtons(java.awt.Container frame) {
ComponentFinder finder = new ComponentFinder(JRadioButton.class);
List<JRadioButton> list = finder.findAll(frame);
Assert.assertNotNull("JRadioButton list not found", list);
return list;
}
use of junit.extensions.jfcunit.finder.ComponentFinder in project JMRI by JMRI.
the class NXFrameTest method confirmJOptionPane.
// For types from DialogFinder().findAll(..)
@SuppressWarnings("unchecked")
private void confirmJOptionPane(java.awt.Container frame, String title, String message, String buttonLabel) {
ComponentFinder finder = new ComponentFinder(JOptionPane.class);
JOptionPane pane;
if (frame == null) {
pane = (JOptionPane) finder.find();
Assert.assertNotNull(title + " JOptionPane not found", pane);
} else {
List<JOptionPane> list = finder.findAll(frame);
Assert.assertNotNull(title + " JOptionPane not found", list);
Assert.assertTrue(title + " JOptionPane not found", list.size() == 1);
// java.util.Iterator iter = list.iterator();
pane = list.get(0);
}
if (message != null) {
Assert.assertEquals(title + " JOptionPane message", message, pane.getMessage());
}
pressButton(pane, buttonLabel);
}
use of junit.extensions.jfcunit.finder.ComponentFinder in project JMRI by JMRI.
the class MemoryIconTest method getColor.
int[] getColor(String frameName, String label, int x, int y, int n) {
// Find window by name
JmriJFrame frame = JmriJFrame.getFrame(frameName);
Assert.assertNotNull("frame: " + frameName, frame);
// find label within that
ComponentFinder finder = new ComponentFinder(MemoryIcon.class);
// FIXME: finder.findAll returns an untyped list, so we have issues with casting
@SuppressWarnings("rawtypes") java.util.List list = finder.findAll(frame);
Assert.assertNotNull("list: " + frameName, list);
Assert.assertTrue("length: " + frameName + ": " + list.size(), list.size() > 0);
// find a point in mid-center of memory icon - location choosen by
// looking at v4.0.1 on Mac
Point p = SwingUtilities.convertPoint(((JComponent) list.get(0)), x, y, frame);
// check pixel color (from http://stackoverflow.com/questions/13307962/how-to-get-the-color-of-a-point-in-a-jpanel )
BufferedImage image = new BufferedImage(400, 300, BufferedImage.TYPE_4BYTE_ABGR);
Graphics2D g2 = image.createGraphics();
frame.paint(g2);
// display a sweep of color
int[] colors = new int[n];
for (int i = 0; i < n; i++) {
int color = image.getRGB(p.x + i, p.y);
//System.err.println(" "+i+" "+String.format("0x%8s", Integer.toHexString(color)).replace(' ', '0'));
colors[i] = color;
}
g2.dispose();
return colors;
}
Aggregations