Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 76   Methods: 6
NCLOC: 62   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JTableRecorderTest.java 100% 96.6% 83.3% 95.9%
coverage coverage
 1   
 package abbot.editor.recorder;
 2   
 
 3   
 import java.awt.event.InputEvent;
 4   
 import javax.swing.JScrollPane;
 5   
 import javax.swing.JTable;
 6   
 
 7   
 import junit.extensions.abbot.RepeatHelper;
 8   
 import abbot.script.Resolver;
 9   
 import abbot.tester.*;
 10   
 
 11   
 /**
 12   
  * Unit test to verify proper capture of user semantic events on a JTable.
 13   
  */
 14   
 public class JTableRecorderTest 
 15   
     extends AbstractSemanticRecorderFixture {
 16   
 
 17   
     private JTableTester tester;
 18   
     private JTable table;
 19   
     private static final int MAX_ENTRIES = 4;
 20   
 
 21  2
     public JTableRecorderTest(String name) {
 22  2
         super(name);
 23   
     }
 24   
 
 25  38
     protected SemanticRecorder createSemanticRecorder(Resolver r) {
 26  38
         return new JTableRecorder(r);
 27   
     }
 28   
 
 29  2
     private void showTable() {
 30  2
         String[][] cells = new String[MAX_ENTRIES][MAX_ENTRIES];
 31  2
         for (int i=0;i < MAX_ENTRIES;i++) {
 32  8
             for (int j=0;j < MAX_ENTRIES;j++) {
 33  32
                 if (i == 0 && j == 0)
 34  2
                     cells[i][j] = null;
 35   
                 else
 36  30
                     cells[i][j] = "cell " + i + "," + j;
 37   
             }
 38   
         }
 39  2
         String[] names = new String[MAX_ENTRIES];
 40  2
         for (int i=0;i < MAX_ENTRIES;i++) {
 41  8
             names[i] = "col " + i;
 42   
         }
 43  2
         table = new JTable(cells, names);
 44  2
         tester = (JTableTester)ComponentTester.getTester(table);
 45  2
         showFrame(new JScrollPane(table));
 46   
     }
 47   
 
 48  1
     public void testCaptureCellSelection() {
 49  1
         showTable();
 50  1
         startRecording();
 51  1
         for (int i=MAX_ENTRIES-1;i >= 0; i--) {
 52  4
             for (int j=MAX_ENTRIES-1; j >= 0;j--) {
 53  16
                 tester.actionSelectCell(table, i, j);
 54  16
                 if (i == 0 && j == 0)
 55  1
                     assertStep("SelectCell\\(.*,\"null\"\\)");
 56   
                 else
 57  15
                     assertStep("SelectCell\\(.*,\"cell " + i + "," + j + "\"\\)");
 58   
             }
 59   
         }
 60   
     }
 61   
 
 62  1
     public void testCaptureMultipleClick() {
 63  1
         showTable();
 64  1
         startRecording();
 65  1
         int row = MAX_ENTRIES/2;
 66  1
         int col = MAX_ENTRIES/2;
 67  1
         tester.actionClick(table, new JTableLocation(row, col),
 68   
                            InputEvent.BUTTON1_MASK, 2);
 69  1
         assertStep("Click\\(.*,\"cell " + row + "," + col + "\",BUTTON1_MASK,2\\)");
 70   
     }
 71   
 
 72  0
     public static void main(String[] args) {
 73  0
         RepeatHelper.runTests(args, JTableRecorderTest.class);
 74   
     }
 75   
 }
 76