Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 257   Methods: 22
NCLOC: 143   Classes: 2
 
 Source file Conditionals Statements Methods TOTAL
AbstractEventDataT.java - 94.4% 77.3% 91%
coverage coverage
 1   
 package junit.extensions.jfcunit.eventdata;
 2   
 
 3   
 import junit.extensions.jfcunit.JFCTestCase;
 4   
 
 5   
 import java.awt.AWTEvent;
 6   
 import java.awt.Component;
 7   
 import java.awt.Point;
 8   
 import java.awt.Rectangle;
 9   
 
 10   
 /**
 11   
  * Data container class that holds all the data necessary for jfcUnit to fire mouse events.
 12   
  *
 13   
  * @author Kevin Wilson
 14   
  * @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
 15   
  */
 16   
 public class AbstractEventDataT extends JFCTestCase implements EventDataConstants {
 17   
     /**
 18   
      * @author Kevin Wilson
 19   
      */
 20   
     class MyTestClass extends AbstractEventData {
 21   
         /**
 22   
          * Dummy canConsume.
 23   
          * @param e Event.
 24   
          * @return false.
 25   
          */
 26  0
         public boolean canConsume(final AWTEvent e) {
 27  0
             return false;
 28   
         }
 29   
 
 30   
         /**
 31   
          * Dummy consume.
 32   
          * @param e Event.
 33   
          * @return false.
 34   
          */
 35  0
         public boolean consume(final AWTEvent e) {
 36  0
             return false;
 37   
         }
 38   
 
 39   
         /**
 40   
          * Dummy getComponent.
 41   
          * @return null
 42   
          */
 43  0
         public Component getComponent() {
 44  0
             return null;
 45   
         }
 46   
 
 47   
         /**
 48   
          * Get the default modifiers.
 49   
          * @return int default modifiers.
 50   
          */
 51  0
         public int getDefaultModifiers() {
 52  0
           return EventDataConstants.DEFAULT_MOUSE_MODIFIERS;
 53   
         }
 54   
 
 55   
         /**
 56   
          * Get the modifier text.
 57   
          * @return null not implemented.
 58   
          */
 59  0
         public String getModifierText() {
 60  0
           return null;
 61   
         }
 62   
 
 63   
     }
 64   
 
 65   
     /**
 66   
      * Default constructor that accepts a String.
 67   
      *
 68   
      * @param   name      The name of the test method to execute.
 69   
      */
 70  15
     public AbstractEventDataT(final String name) {
 71  15
         super(name);
 72   
     }
 73   
 
 74   
     /**
 75   
      * Overridden method that is used to remove the test fixtures.
 76   
      *
 77   
      * @exception  Exception   An instance of Exception can be thrown.
 78   
      */
 79  15
     protected void tearDown() throws Exception {
 80  15
         super.tearDown();
 81   
     }
 82   
 
 83   
 
 84   
 
 85   
     /**
 86   
      * Test calculation of north position.
 87   
      */
 88  1
     public void testCalculateNorth() {
 89  1
         MyTestClass myClass = new MyTestClass();
 90  1
         myClass.setPosition(NORTH);
 91  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 92  1
         Point v = new Point(3, 0);
 93  1
         assertEquals("North:", v, l);
 94   
     }
 95   
 
 96   
     /**
 97   
      * Test calculation of northeast position.
 98   
      */
 99  1
     public void testCalculateNorthEast() {
 100  1
         MyTestClass myClass = new MyTestClass();
 101  1
         myClass.setPosition(NORTH_EAST);
 102  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 103  1
         Point v = new Point(7, 0);
 104  1
         assertEquals("NorthEast:", v, l);
 105   
     }
 106   
 
 107   
     /**
 108   
      * Test calculation of east position.
 109   
      */
 110  1
     public void testCalculateEast() {
 111  1
         MyTestClass myClass = new MyTestClass();
 112  1
         myClass.setPosition(EAST);
 113  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 114  1
         Point v = new Point(7, 3);
 115  1
         assertEquals("Nort:", v, l);
 116   
     }
 117   
 
 118   
     /**
 119   
      * Test calculation of southeast position.
 120   
      */
 121  1
     public void testCalculateSouthEast() {
 122  1
         MyTestClass myClass = new MyTestClass();
 123  1
         myClass.setPosition(SOUTH_EAST);
 124  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 125  1
         Point v = new Point(7, 7);
 126  1
         assertEquals("SouthEast:", v, l);
 127   
     }
 128   
 
 129   
     /**
 130   
      * Test calculation of south position.
 131   
      */
 132  1
     public void testCalculateSouth() {
 133  1
         MyTestClass myClass = new MyTestClass();
 134  1
         myClass.setPosition(SOUTH);
 135  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 136  1
         Point v = new Point(3, 7);
 137  1
         assertEquals("South:", v, l);
 138   
     }
 139   
 
 140   
     /**
 141   
      * Test calculation of southwest position.
 142   
      */
 143  1
     public void testCalculateSouthWest() {
 144  1
         MyTestClass myClass = new MyTestClass();
 145  1
         myClass.setPosition(SOUTH_WEST);
 146  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 147  1
         Point v = new Point(0, 7);
 148  1
         assertEquals("SouthWest:", v, l);
 149   
     }
 150   
 
 151   
     /**
 152   
      * Test calculation of west position.
 153   
      */
 154  1
     public void testCalculateWest() {
 155  1
         MyTestClass myClass = new MyTestClass();
 156  1
         myClass.setPosition(WEST);
 157  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 158  1
         Point v = new Point(0, 3);
 159  1
         assertEquals("West:", v, l);
 160   
     }
 161   
 
 162   
     /**
 163   
      * Test calculation of center position.
 164   
      */
 165  1
     public void testCalculateCenter() {
 166  1
         MyTestClass myClass = new MyTestClass();
 167  1
         myClass.setPosition(CENTER);
 168  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 169  1
         Point v = new Point(3, 3);
 170  1
         assertEquals("Center:", v, l);
 171   
     }
 172   
 
 173   
     /**
 174   
      * Test calculation of custom position.
 175   
      */
 176  1
     public void testCalculateCustom() {
 177  1
         MyTestClass myClass = new MyTestClass();
 178  1
         myClass.setPosition(CUSTOM);
 179  1
         myClass.setReferencePoint(new Point(6, 6));
 180  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 181  1
         Point v = new Point(6, 6);
 182  1
         assertEquals("Custom:", v, l);
 183   
     }
 184   
 
 185   
     /**
 186   
      * Test calculation of custom position.
 187   
      */
 188  1
     public void testCalculateCustom2() {
 189  1
         MyTestClass myClass = new MyTestClass();
 190  1
         myClass.setPosition(CUSTOM);
 191  1
         myClass.setReferencePoint(new Point(2, 4));
 192  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 193  1
         Point v = new Point(2, 4);
 194  1
         assertEquals("Custom:", v, l);
 195   
     }
 196   
 
 197   
     /**
 198   
      * Test calculation of northwest position.
 199   
      */
 200  1
     public void testCalculatePercent() {
 201  1
         MyTestClass myClass = new MyTestClass();
 202  1
         myClass.setPosition(PERCENT);
 203  1
         myClass.setReferencePoint(new Point(0, 0));
 204  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 205  1
         Point v = new Point(0, 0);
 206  1
         assertEquals("Percent:", v, l);
 207   
     }
 208   
 
 209   
     /**
 210   
      * Test calculation of southwest position with percent.
 211   
      */
 212  1
     public void testCalculatePercent2() {
 213  1
         MyTestClass myClass = new MyTestClass();
 214  1
         myClass.setPosition(PERCENT);
 215  1
         myClass.setReferencePoint(new Point(0, 100));
 216  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 217  1
         Point v = new Point(0, 7);
 218  1
         assertEquals("Percent2:", v, l);
 219   
     }
 220   
 
 221   
     /**
 222   
      * Test calculation of southeast position with percent.
 223   
      */
 224  1
     public void testCalculatePercent3() {
 225  1
         MyTestClass myClass = new MyTestClass();
 226  1
         myClass.setPosition(PERCENT);
 227  1
         myClass.setReferencePoint(new Point(100, 100));
 228  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 229  1
         Point v = new Point(7, 7);
 230  1
         assertEquals("Percent3:", v, l);
 231   
     }
 232   
 
 233   
     /**
 234   
      * Test calculation of northeast position with percent.
 235   
      */
 236  1
     public void testCalculatePercent4() {
 237  1
         MyTestClass myClass = new MyTestClass();
 238  1
         myClass.setPosition(PERCENT);
 239  1
         myClass.setReferencePoint(new Point(100, 0));
 240  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 241  1
         Point v = new Point(7, 0);
 242  1
         assertEquals("Percent4:", v, l);
 243   
     }
 244   
 
 245   
     /**
 246   
      * Test calculation of center position with percent.
 247   
      */
 248  1
     public void testCalculatePercent5() {
 249  1
         MyTestClass myClass = new MyTestClass();
 250  1
         myClass.setPosition(PERCENT);
 251  1
         myClass.setReferencePoint(new Point(50, 50));
 252  1
         Point l = myClass.calculatePoint(new Rectangle(0, 0, 7, 7));
 253  1
         Point v = new Point(3, 3);
 254  1
         assertEquals("Percent5:", v, l);
 255   
     }
 256   
 }
 257