Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 174   Methods: 4
NCLOC: 36   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JListMouseEventDataTagHandler.java - 87.5% 100% 91.7%
coverage coverage
 1   
 package junit.extensions.jfcunit.eventdata;
 2   
 
 3   
 import junit.extensions.xml.IXMLTestCase;
 4   
 import junit.extensions.xml.XMLException;
 5   
 
 6   
 import org.w3c.dom.Element;
 7   
 
 8   
 import javax.swing.JList;
 9   
 
 10   
 
 11   
 /**
 12   
  * This is a extension of the click and drag elements. Where the
 13   
  * type specified is JListMouseEventData.
 14   
  *
 15   
  * <h3>Description</h3>
 16   
  * <p>
 17   
  *   Nothing is invoked directly by this tag handler. The click and drag elements
 18   
  *   use this tag handler to customize the data specificly for the type specified.
 19   
  * </p>
 20   
  * <p>
 21   
  *   For now this class requires the index. It does not yet provide methods for
 22   
  *   searching for tabs based upon the text or icon contained. These are left
 23   
  *   for future enhancements.
 24   
  * </p>
 25   
  *
 26   
  * <h3>Parameters</h3>
 27   
  * <table border="1" cellpadding="2" cellspacing="0">
 28   
  *   <tr>
 29   
  *     <td valign="top"><b>Attribute</b></td>
 30   
  *     <td valign="top"><b>Description</b></td>
 31   
  *     <td align="center" valign="top"><b>Required</b></td>
 32   
  *     <td valign="top"><b>Default</b></td>
 33   
  *     <td valign="top"><b>Values</b></td>
 34   
  *   </tr>
 35   
  *   <tr>
 36   
  *     <td valign="top">type</td>
 37   
  *     <td valign="top">For this element the type must be set to MouseEventData</td>
 38   
  *     <td valign="top" align="center">Yes</td>
 39   
  *     <td valign="top">N/A</td>
 40   
  *     <td valign="top">N/A</td>
 41   
  *   </tr>
 42   
  *   <tr>
 43   
  *     <td valign="top">refid</td>
 44   
  *     <td valign="top">Id of a object reference which has been previously found.</td>
 45   
  *     <td valign="top" align="center">Yes</td>
 46   
  *     <td valign="top">N/A</td>
 47   
  *     <td valign="top">N/A</td>
 48   
  *   </tr>
 49   
  *   <tr>
 50   
  *     <td valign="top">index</td>
 51   
  *     <td valign="top">The index of the element to select from the list.</td>
 52   
  *     <td valign="top" align="center">Yes</td>
 53   
  *     <td valign="top">-1</td>
 54   
  *     <td valign="top">Zero based index of list items.</td>
 55   
  *   </tr>
 56   
  *   <tr>
 57   
  *     <td valign="top">clicks</td>
 58   
  *     <td valign="top">The number of clicks to be executed.</td>
 59   
  *     <td valign="top" align="center">No</td>
 60   
  *     <td valign="top">1</td>
 61   
  *     <td valign="top">Positive Integer</td>
 62   
  *   </tr>
 63   
  *   <tr>
 64   
  *     <td valign="top">modifiers</td>
 65   
  *     <td valign="top">The modifiers to be used for this event.</td>
 66   
  *     <td valign="top" align="center">No</td>
 67   
  *     <td valign="top">Button1 if popup is false otherwise Button3</td>
 68   
  *     <td valign="top">alt altgr control meta shift button1 button2 button3</td>
 69   
  *   </tr>
 70   
  *   <tr>
 71   
  *     <td valign="top">popup</td>
 72   
  *     <td valign="top">True if this is event is using the popup button.</td>
 73   
  *     <td valign="top" align="center">No</td>
 74   
  *     <td valign="top">false</td>
 75   
  *     <td valign="top">true false</td>
 76   
  *   </tr>
 77   
  *   <tr>
 78   
  *     <td valign="top">sleeptime</td>
 79   
  *     <td valign="top">Maximum sleep time</td>
 80   
  *     <td valign="top" align="center">No</td>
 81   
  *     <td valign="top">500</td>
 82   
  *     <td valign="top">Positive Integer representing the milli-seconds</td>
 83   
  *   </tr>
 84   
  *   <tr>
 85   
  *     <td valign="top">position</td>
 86   
  *     <td valign="top">Positioning of the mouse within the bounds of the component.</td>
 87   
  *     <td valign="top" align="center">No</td>
 88   
  *     <td valign="top">center</td>
 89   
  *     <td valign="top">center north northeast east southeast south southwest west northwest custom percentage</td>
 90   
  *   </tr>
 91   
  *   <tr>
 92   
  *     <td valign="top">reference</td>
 93   
  *     <td valign="top">Reference point or number for position calculation.</td>
 94   
  *     <td valign="top" align="center">No</td>
 95   
  *     <td valign="top">null</td>
 96   
  *     <td valign="top">integers &quot;x,y&quot;</td>
 97   
  *   </tr>
 98   
  *
 99   
  * </table>
 100   
  * <h3>Example</h3>
 101   
  * <blockquote><pre>
 102   
  * &lt;click
 103   
  *    type=&quot;JListMouseEventData&quot;
 104   
  *    refid=&quot;List&quot;
 105   
  *    index=&quot;1&quot;
 106   
  * /&gt;
 107   
  * </pre></blockquote>
 108   
  * <p>
 109   
  * The above clicks once on the center of the component identified by
 110   
  * List.
 111   
  * </p>
 112   
  * @see junit.extensions.jfcunit.eventdata.JListMouseEventData
 113   
  * @author Kevin Wilson
 114   
  */
 115   
 public class JListMouseEventDataTagHandler extends BaseEventDataTagHandler {
 116   
     /**
 117   
      * Constructor for JListMouseEventDataTagHandler.
 118   
      *
 119   
      * @param element     The element to be processed
 120   
      * @param testCase    The IXMLTestCase that uses this element
 121   
      */
 122  20
     public JListMouseEventDataTagHandler(final Element element,
 123   
         final IXMLTestCase testCase) {
 124  20
         super(element, testCase);
 125   
     }
 126   
 
 127   
     /**
 128   
      * @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
 129   
      * @throws XMLException when validation fails.
 130   
      */
 131  20
     public void processElement() throws XMLException {
 132  20
         validateElement();
 133  20
         setEventData(
 134   
             new JListMouseEventData(
 135   
                 getJFCTestCase(),
 136   
                 (JList) getComponent(),
 137   
                 getIndex(),
 138   
                 getClicks(),
 139   
                 getModifiers(),
 140   
                 getPopupTrigger(),
 141   
                 getSleepTime(),
 142   
                 getPosition(),
 143   
                 getReference()));
 144   
     }
 145   
 
 146   
     /**
 147   
      * @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
 148   
      * @throws XMLException when validation fails.
 149   
      */
 150  20
     public void validateElement() throws XMLException {
 151   
         // do the default validations from the super class
 152  20
         super.validateElement();
 153   
 
 154   
         /**
 155   
          * @todo Should be able to find the object to select.
 156   
          * For now we will require the index.
 157   
          * index into combo box.
 158   
          */
 159  20
         checkRequiredAttribute(INDEX);
 160   
     }
 161   
 
 162   
     /**
 163   
      * Returns the value of the INDEX attribute for this element. Defaults to 0 (zero) if not found.
 164   
      * @return int  The value of the parsed INDEX attribute, zero if not found.
 165   
      */
 166  20
     private int getIndex() {
 167  20
         try {
 168  20
             return getInt(INDEX, 0);
 169   
         } catch (NumberFormatException e) {
 170  0
             throw new NumberFormatException("Index not formatted properly");
 171   
         }
 172   
     }
 173   
 }
 174