Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 216   Methods: 6
NCLOC: 67   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JMenuMouseEventDataTagHandler.java 0% 0% 0% 0%
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 java.util.StringTokenizer;
 9   
 
 10   
 import javax.swing.JComponent;
 11   
 
 12   
 
 13   
 /**
 14   
  * This is a extension of the click and drag elements. Where the
 15   
  * type specified is JMenuMouseEventData.
 16   
  *
 17   
  * <h3>Description</h3>
 18   
  * <p>
 19   
  *   Nothing is invoked directly by this tag handler. The click and drag elements
 20   
  *   use this tag handler to customize the data specificly for the JMenu.
 21   
  * </p>
 22   
  *
 23   
  * <h3>Parameters</h3>
 24   
  * <table border="1" cellpadding="2" cellspacing="0">
 25   
  *   <tr>
 26   
  *     <td valign="top"><b>Attribute</b></td>
 27   
  *     <td valign="top"><b>Description</b></td>
 28   
  *     <td align="center" valign="top"><b>Required</b></td>
 29   
  *     <td valign="top"><b>Default</b></td>
 30   
  *     <td valign="top"><b>Values</b></td>
 31   
  *   </tr>
 32   
  *   <tr>
 33   
  *     <td valign="top">type</td>
 34   
  *     <td valign="top">For this element the type must be set to JMenuMouseEventData</td>
 35   
  *     <td valign="top" align="center">Yes</td>
 36   
  *     <td valign="top">N/A</td>
 37   
  *     <td valign="top">N/A</td>
 38   
  *   </tr>
 39   
  *   <tr>
 40   
  *     <td valign="top">refid</td>
 41   
  *     <td valign="top">Id of a object reference which has been previously found.</td>
 42   
  *     <td valign="top" align="center">Yes</td>
 43   
  *     <td valign="top">N/A</td>
 44   
  *     <td valign="top">N/A</td>
 45   
  *   </tr>
 46   
  *   <tr>
 47   
  *     <td valign="top">node</td>
 48   
  *     <td valign="top">Yes</td>
 49   
  *     <td valign="top" align="center">Yes</td>
 50   
  *     <td valign="top">N/A</td>
 51   
  *     <td valign="top">Must be string specifying the value of the node.</td>
 52   
  *   </tr>
 53   
  *   <tr>
 54   
  *     <td valign="top">clicks</td>
 55   
  *     <td valign="top">The number of clicks to be executed.</td>
 56   
  *     <td valign="top" align="center">No</td>
 57   
  *     <td valign="top">1</td>
 58   
  *     <td valign="top">Positive Integer</td>
 59   
  *   </tr>
 60   
  *   <tr>
 61   
  *     <td valign="top">modifiers</td>
 62   
  *     <td valign="top">The modifiers to be used for this event.</td>
 63   
  *     <td valign="top" align="center">No</td>
 64   
  *     <td valign="top">Button1 if popup is false otherwise Button3</td>
 65   
  *     <td valign="top">alt altgr control meta shift button1 button2 button3</td>
 66   
  *   </tr>
 67   
  *   <tr>
 68   
  *     <td valign="top">popup</td>
 69   
  *     <td valign="top">True if this is event is using the popup button.</td>
 70   
  *     <td valign="top" align="center">No</td>
 71   
  *     <td valign="top">false</td>
 72   
  *     <td valign="top">true false</td>
 73   
  *   </tr>
 74   
  *   <tr>
 75   
  *     <td valign="top">sleeptime</td>
 76   
  *     <td valign="top">Maximum sleep time</td>
 77   
  *     <td valign="top" align="center">No</td>
 78   
  *     <td valign="top">500</td>
 79   
  *     <td valign="top">Positive Integer representing the milli-seconds</td>
 80   
  *   </tr>
 81   
  *   <tr>
 82   
  *     <td valign="top">position</td>
 83   
  *     <td valign="top">Positioning of the mouse within the bounds of the component.</td>
 84   
  *     <td valign="top" align="center">No</td>
 85   
  *     <td valign="top">center</td>
 86   
  *     <td valign="top">center north northeast east southeast south southwest west northwest custom percentage</td>
 87   
  *   </tr>
 88   
  *   <tr>
 89   
  *     <td valign="top">reference</td>
 90   
  *     <td valign="top">Reference point or number for position calculation.</td>
 91   
  *     <td valign="top" align="center">No</td>
 92   
  *     <td valign="top">null</td>
 93   
  *     <td valign="top">integers &quot;x,y&quot;</td>
 94   
  *   </tr>
 95   
  *
 96   
  * </table>
 97   
  * <h3>Example</h3>
 98   
  * <blockquote><pre>
 99   
  * &lt;click
 100   
  *    type=&quot;JMenuMouseEventData&quot;
 101   
  *    refid=&quot;Menu&quot;
 102   
  *    node=&quot;Music&quot;
 103   
  * /&gt;
 104   
  * </pre></blockquote>
 105   
  * <p>
 106   
  * The above clicks once on the center of the component identified by
 107   
  * Menu.
 108   
  * </p>
 109   
  * @see junit.extensions.jfcunit.eventdata.JMenuMouseEventData
 110   
  * @author Kevin Wilson
 111   
  */
 112   
 public class JMenuMouseEventDataTagHandler extends BaseEventDataTagHandler {
 113   
     /**
 114   
      * Constructor for JMenuMouseEventDataTagHandler.
 115   
      *
 116   
      * @param element     The element to be processed
 117   
      * @param testCase    The IXMLTestCase that uses this element
 118   
      */
 119  0
     public JMenuMouseEventDataTagHandler(final Element element,
 120   
         final IXMLTestCase testCase) {
 121  0
         super(element, testCase);
 122   
     }
 123   
 
 124   
     /**
 125   
      * @see junit.extensions.xml.elements.AbstractTagHandler#processElement()
 126   
      * @throws XMLException provided to complete contract only.
 127   
      */
 128  0
     public void processElement() throws XMLException {
 129  0
         validateElement();
 130   
 
 131  0
         JComponent mb = (JComponent) getComponent();
 132   
 
 133  0
         int[]      indexes = getIndexes();
 134   
 
 135  0
         if (indexes == null) {
 136  0
             String path = getPath();
 137   
 
 138  0
             if (path != null) {
 139  0
                 PathTagHandler pdth = new PathTagHandler(
 140   
                         getElement(),
 141   
                         getXMLTestCase());
 142  0
                 PathData       pd = pdth.getPathData();
 143  0
                 indexes = pd.getIndexes(mb);
 144   
             } else {
 145  0
                 String   pathName = getPathRefid();
 146  0
                 PathData pd = (PathData) getXMLTestCase().getProperty(pathName);
 147  0
                 indexes = pd.getIndexes(mb);
 148   
             }
 149   
         }
 150   
 
 151  0
         setEventData(
 152   
             new JMenuMouseEventData(
 153   
                 getJFCTestCase(),
 154   
                 mb,
 155   
                 indexes,
 156   
                 getClicks(),
 157   
                 getModifiers(),
 158   
                 getPopupTrigger(),
 159   
                 getSleepTime()));
 160   
     }
 161   
 
 162   
     /**
 163   
      * @see junit.extensions.xml.elements.AbstractTagHandler#validateElement()
 164   
      * @throws XMLException provided to complete contract only.
 165   
      */
 166  0
     public void validateElement() throws XMLException {
 167   
         // do the default validations from the super class
 168  0
         super.validateElement();
 169   
     }
 170   
 
 171   
     /**
 172   
      * Get the indexes attribute.
 173   
      * @return int[] of indexes.
 174   
      */
 175  0
     private int[] getIndexes() {
 176  0
         String data = getString(INDEXES);
 177   
 
 178  0
         if (data == null) {
 179  0
             return null;
 180   
         }
 181   
 
 182  0
         String delimiter = getString(DELIMITER);
 183   
 
 184  0
         if (delimiter == null) {
 185  0
             delimiter = ",";
 186   
         }
 187   
 
 188  0
         StringTokenizer tok     = new StringTokenizer(data, delimiter);
 189  0
         int[]           indexes = new int[tok.countTokens()];
 190  0
         int             i       = 0;
 191   
 
 192  0
         while (tok.hasMoreTokens()) {
 193  0
             String token = tok.nextToken();
 194  0
             indexes[i++] = Integer.parseInt(token);
 195   
         }
 196   
 
 197  0
         return indexes;
 198   
     }
 199   
 
 200   
     /**
 201   
      * Get the path attribute.
 202   
      * @return Path attribute.
 203   
      */
 204  0
     private String getPath() {
 205  0
         return getString(PATH);
 206   
     }
 207   
 
 208   
     /**
 209   
      * Get the path refid.
 210   
      * @return Path Reference ID.
 211   
      */
 212  0
     private String getPathRefid() {
 213  0
         return getString(PATHREFID);
 214   
     }
 215   
 }
 216