Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 99   Methods: 7
NCLOC: 80   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JTextComponentRecorderTest.java - 98.1% 85.7% 96.7%
coverage coverage
 1   
 package abbot.editor.recorder;
 2   
 
 3   
 import java.awt.event.KeyEvent;
 4   
 
 5   
 import javax.swing.JTextField;
 6   
 import javax.swing.JLabel;
 7   
 import javax.swing.JPanel;
 8   
 
 9   
 import junit.extensions.abbot.RepeatHelper;
 10   
 import abbot.script.Resolver;
 11   
 import abbot.tester.JTextComponentTester;
 12   
 
 13   
 /** Test recording of JTextComponent-specific events. */
 14   
 public class JTextComponentRecorderTest 
 15   
     extends AbstractSemanticRecorderFixture {
 16   
 
 17   
     private JTextComponentTester tester = new JTextComponentTester();
 18   
 
 19   
     // FIXME select action failure on first run on Linux/1.4.2
 20  1
     public void testCaptureSelection(){ 
 21  1
         String text = "Select some text";
 22  1
         JTextField tf = new JTextField(text);
 23  1
         JPanel p = new JPanel();
 24  1
         p.add(tf);
 25  1
         p.add(new JLabel(getName()));
 26  1
         showFrame(p);
 27  1
         startRecording();
 28  1
         tester.actionSelectText(tf, 1, text.length()-1);
 29  1
         assertStep("SelectText\\(.*,1," + (text.length()-1) + "\\)");
 30  1
         tester.actionSelectText(tf, 0, 5);
 31  1
         assertStep("SelectText\\(.*,0,5\\)");
 32  1
         tester.actionSelectText(tf, 4, text.length());
 33  1
         assertStep("SelectText\\(.*,4," + text.length() + "\\)");
 34  1
         tester.actionSelectText(tf, 0, text.length());
 35  1
         assertStep("SelectText\\(.*,0," + text.length() + "\\)");
 36   
     }
 37   
 
 38  1
     public void testCaptureReverseSelection() {
 39  1
         String text = "Select me backwards";
 40  1
         JTextField tf = new JTextField(text);
 41  1
         JPanel p = new JPanel();
 42  1
         p.add(tf);
 43  1
         p.add(new JLabel(getName()));
 44  1
         showFrame(p);
 45  1
         startRecording();
 46  1
         tester.actionSelectText(tf, text.length()-1, 1);
 47  1
         assertStep("SelectText\\(.*," + (text.length()-1) + ",1\\)");
 48  1
         tester.actionSelectText(tf, 5, 0);
 49  1
         assertStep("SelectText\\(.*,5,0\\)");
 50  1
         tester.actionSelectText(tf, text.length(), 4);
 51  1
         assertStep("SelectText\\(.*," + text.length() + ",4\\)");
 52  1
         tester.actionSelectText(tf, text.length(), 0);
 53  1
         assertStep("SelectText\\(.*," + text.length() + ",0\\)");
 54   
     }
 55   
 
 56   
     // FIXME NPE due to improper drag/drop recording on linux/1.4.2
 57  1
     public void testCaptureScrollingSelection(){ 
 58  1
         String text = "Select some text";
 59  1
         JTextField tf = new JTextField(text);
 60  1
         JPanel p = new JPanel();
 61  1
         p.add(tf);
 62  1
         p.add(new JLabel(getName()));
 63  1
         showFrame(p);
 64  1
         tester.actionSelectText(tf, 1, text.length()-1);
 65  1
         startRecording();
 66  1
         tester.actionDrag(tf, 1, tf.getHeight()/2);
 67  1
         tester.actionDrop(tf, tf.getWidth() + 100, tf.getHeight()/2);
 68  1
         assertStep("SelectText\\(.*,0," + text.length() + "\\)");
 69   
     }
 70   
 
 71  1
     public void testCaptureSetCaretPosition() {
 72  1
         String text = "Set the caret position";
 73  1
         JTextField tf = new JTextField(text);
 74  1
         showFrame(tf);
 75  1
         startRecording();
 76  1
         tester.actionClick(tf, 0);
 77  1
         assertStep("Click\\(.*,0\\)");
 78   
 
 79  1
         tester.actionClick(tf, text.length()-1);
 80  1
         assertStep("Click\\(.*," + (text.length()-1) + "\\)");
 81   
 
 82  1
         tester.actionClick(tf, text.length()/2);
 83  1
         assertStep("Click\\(.*," + (text.length()/2) + "\\)");
 84   
     }
 85   
 
 86   
     /** Create a new test case with the given name. */
 87  4
     public JTextComponentRecorderTest(String name) {
 88  4
         super(name);
 89   
     }
 90   
 
 91  26
     protected SemanticRecorder createSemanticRecorder(Resolver r) {
 92  26
         return new JTextComponentRecorder(r);
 93   
     }
 94   
 
 95  0
     public static void main(String[] args) {
 96  0
         RepeatHelper.runTests(args, JTextComponentRecorderTest.class);
 97   
     }
 98   
 }
 99