Advertisement
jdalbey

JTable Demo GUI Unit Test with UISpec4J

Oct 6th, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5 1.35 KB | None | 0 0
  1. import junit.framework.TestCase;
  2. import org.uispec4j.*;
  3.  
  4. /**
  5.  * A simple test of the JTableDemo GUI using UISpec4J.
  6.  * @author jdalbey
  7.  */
  8. public class JTableDemoTest extends TestCase
  9. {
  10.     public JTableDemoTest(String testName)
  11.     {
  12.         super(testName);
  13.     }
  14.  
  15.     public void testOne()
  16.     {
  17.         JTableDemo view = new JTableDemo();
  18.         view.layoutGUI();
  19.         /* Note: Window and Table are UISpec4J classes */
  20.         Window win = new Window(view);
  21.         Table table = win.getTable("table");
  22.         // Inspect one cell of the table
  23.         Renderable p = (Renderable) table.getContentAt(1,1, new ModelTableCellValueConverter());
  24.         // It should contain the piece symbol.
  25.         assertEquals("O", p.getText());
  26.         // make a move
  27.         table.click(1,1);
  28.         // See if the cell content changed
  29.         p = (Renderable) table.getContentAt(1,1, new ModelTableCellValueConverter());
  30.         // Empty table cells contain null.
  31.         assertEquals(null, p);
  32.     }
  33.     public void testTwo()
  34.     {
  35.         JTableDemo view = new JTableDemo();
  36.         view.layoutGUI();
  37.         Window win = new Window(view);
  38.         TextBox theLabel = win.getTextBox("status");
  39.         assertEquals("###", theLabel.getText());
  40.         win.getTable("table").click(1,1);
  41.         assertEquals("1", theLabel.getText());
  42.     }
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement