Clover coverage report - clover
Coverage timestamp: Sat Oct 8 2005 22:54:17 EDT
file stats: LOC: 91   Methods: 8
NCLOC: 68   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
ChoiceRecorderTest.java 75% 93.8% 87.5% 90.9%
coverage coverage
 1   
 package abbot.editor.recorder;
 2   
 
 3   
 import java.awt.*;
 4   
 import java.awt.event.*;
 5   
 
 6   
 import javax.swing.*;
 7   
 
 8   
 import junit.extensions.abbot.RepeatHelper;
 9   
 import abbot.Platform;
 10   
 import abbot.script.Resolver;
 11   
 import abbot.tester.*;
 12   
 import abbot.util.Bugs;
 13   
 
 14   
 /**
 15   
  * Unit test to verify proper capture of user semantic events on a Choice.
 16   
  */
 17   
 public class ChoiceRecorderTest 
 18   
     extends AbstractSemanticRecorderFixture {
 19   
 
 20   
     private Frame frame;
 21   
     private Choice choice;
 22   
     private static final int MAX_ENTRIES = 20;
 23   
 
 24   
     // FIXME linux gets duplicate ITEM_STATE_CHANGED events (VM bug)
 25  1
     public void testCaptureSelection() {
 26  1
         showChoice();
 27  1
         ChoiceTester tester = new ChoiceTester();
 28   
 
 29  1
         startRecording();
 30  1
         tester.actionSelectIndex(choice, MAX_ENTRIES - 1);
 31  1
         assertStep("SelectItem(.*,item "
 32   
                    + (MAX_ENTRIES - 1) + ")");
 33  1
         if (Bugs.hasChoiceLockupBug()) {
 34  0
             return;
 35   
         }
 36   
 
 37   
         //startRecording();
 38  1
         tester.actionSelectIndex(choice, MAX_ENTRIES / 2 - 1);
 39  1
         assertStep("SelectItem(.*,item "
 40   
                    + (MAX_ENTRIES/2 - 1) + ")");
 41   
 
 42   
         //startRecording();
 43  1
         tester.actionSelectIndex(choice, 0);
 44  1
         assertStep("SelectItem(.*,item 0)");
 45   
     }
 46   
 
 47  1
     public void testESCToCancelSelection() {
 48  1
         showChoice();
 49  1
         startRecording();
 50  1
         ComponentTester tester = ComponentTester.getTester(Component.class);
 51  1
         tester.mousePress(choice);
 52  1
         tester.actionKeyStroke(KeyEvent.VK_ESCAPE);
 53  1
         assertNoStep();
 54   
     }
 55   
 
 56  1
     public void testClickToCancelSelection() {
 57  1
         showChoice();
 58  1
         startRecording();
 59  1
         ComponentTester tester = ComponentTester.getTester(Component.class);
 60  1
         tester.mousePress(choice);
 61  1
         JPanel pane = (JPanel)((JFrame)frame).getContentPane();
 62  1
         tester.actionClick(pane, 0, 0);
 63  1
         assertNoStep();
 64   
     }
 65   
 
 66  3
     public ChoiceRecorderTest(String name) {
 67  3
         super(name);
 68   
     }
 69   
 
 70  7
     protected SemanticRecorder createSemanticRecorder(Resolver r) {
 71  7
         return new ChoiceRecorder(r);
 72   
     }
 73   
 
 74  3
     private void showChoice() {
 75  3
         choice = new Choice();
 76  3
         for (int i=0;i < MAX_ENTRIES;i++) {
 77  60
             choice.add("item " + i);
 78   
         }
 79   
         // Must have a listener or no events will be fired
 80  3
         choice.addItemListener(new ItemListener() {
 81  3
             public void itemStateChanged(ItemEvent e) {
 82   
             }
 83   
         });
 84  3
         frame = showFrame(choice);
 85   
     }
 86   
 
 87  0
     public static void main(String[] args) {
 88  0
         RepeatHelper.runTests(args, ChoiceRecorderTest.class);
 89   
     }
 90   
 }
 91