Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 279   Methods: 15
NCLOC: 165   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
MouseWheelEventDataT.java - 100% 100% 100%
coverage
 1   
 package junit.extensions.jfcunit.eventdata;
 2   
 
 3   
 import junit.extensions.jfcunit.JFCTestCase;
 4   
 
 5   
 import java.awt.Component;
 6   
 import java.awt.Point;
 7   
 
 8   
 import javax.swing.JButton;
 9   
 
 10   
 /**
 11   
  * Data container class that holds all the data necessary for
 12   
  * jfcUnit to fire mouse events.
 13   
  *
 14   
  * @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
 15   
  */
 16   
 public class MouseWheelEventDataT
 17   
     extends MouseEventDataBC {
 18   
   /**
 19   
    * Event data to be validated.
 20   
    */
 21   
   private MouseWheelEventData m_event1 = null;
 22   
 
 23   
   /**
 24   
    * Second Event data to be validated.
 25   
    */
 26   
   private MouseWheelEventData m_event2 = null;
 27   
 
 28   
   /**
 29   
    * Component to be tested.
 30   
    */
 31   
   private static final Component COMP1 = new JButton();
 32   
 
 33   
   /**
 34   
    * Second component to be tested.
 35   
    */
 36   
   private static final Component COMP2 = new JButton();
 37   
 
 38   
   /**
 39   
    * Default constructor that accepts a String.
 40   
    *
 41   
    * @param   name      The name of the test method to execute.
 42   
    */
 43  12
   public MouseWheelEventDataT(final String name) {
 44  12
     super(name);
 45   
   }
 46   
 
 47   
   /**
 48   
    * Overridden method that is used to remove the test fixtures.
 49   
    *
 50   
    * @exception  Exception   An instance of java.lang.Exception can be thrown
 51   
    */
 52  12
   protected void tearDown() throws Exception {
 53  12
     super.tearDown();
 54  12
     m_event1 = null;
 55  12
     m_event2 = null;
 56   
   }
 57   
 
 58   
   /**
 59   
    * Validate the parameters of the event match the values
 60   
    * given.
 61   
    *
 62   
    * @param event Event to be tested.
 63   
    * @param tc TestCase.
 64   
    * @param comp component
 65   
    * @param scrollAmount Amount to be scrolled.
 66   
    * @param wheelRotation Amount the wheel was rotated.
 67   
    * @param clicks mouse clicks.
 68   
    * @param modifiers Modifiers to be used.
 69   
    * @param popup Popup.
 70   
    * @param sleepTime sleep duration.
 71   
    * @param position locatio of mouse.
 72   
    * @param ref Reference location.
 73   
    */
 74  20
   protected void validateEvent(
 75   
       final MouseWheelEventData event,
 76   
       final JFCTestCase tc,
 77   
       final Component comp,
 78   
       final int scrollAmount,
 79   
       final int wheelRotation,
 80   
       final int clicks,
 81   
       final int modifiers,
 82   
       final boolean popup,
 83   
       final long sleepTime,
 84   
       final int position,
 85   
       final Point ref) {
 86  20
     super.validateEvent(event, tc, comp, clicks, modifiers, popup, sleepTime,
 87   
                         position, ref);
 88  20
     assertSameOrNull("Source:", comp, event.getSource());
 89   
   }
 90   
 
 91   
   /**
 92   
    * Test the constructor.
 93   
    */
 94  1
   public void testMouseWheelEventData1() {
 95  1
     m_event1 = new MouseWheelEventData();
 96  1
     assertEquals("Should be invalid", false, m_event1.isValid());
 97  1
     assertEquals("Prepare result:", false, m_event1.prepareComponent());
 98   
   }
 99   
 
 100   
   /**
 101   
    * Test the constructor.
 102   
    */
 103  1
   public void testMouseWheelEventData2() {
 104  1
     m_event1 = new MouseWheelEventData(this, COMP1);
 105  1
     validateEvent(m_event1, this, COMP1, 3, 1, 0, DEFAULT_MOUSE_MODIFIERS,
 106   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 107   
 
 108  1
     m_event2 = new MouseWheelEventData(this, COMP2);
 109  1
     validateEvent(m_event2, this, COMP2, 3, 1, 0, DEFAULT_MOUSE_MODIFIERS,
 110   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 111   
   }
 112   
 
 113   
   /**
 114   
    * Test the constructor.
 115   
    */
 116  1
   public void testMouseWheelEventData3() {
 117  1
     m_event1 = new MouseWheelEventData(this, COMP1, -1);
 118  1
     validateEvent(m_event1, this, COMP1, 3, -1, 0, DEFAULT_MOUSE_MODIFIERS,
 119   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 120   
 
 121  1
     m_event2 = new MouseWheelEventData(this, COMP2, 2);
 122  1
     validateEvent(m_event2, this, COMP2, 3, 2, 0, DEFAULT_MOUSE_MODIFIERS,
 123   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 124   
   }
 125   
 
 126   
   /**
 127   
    * Test the constructor.
 128   
    */
 129  1
   public void testMouseWheelEventData4() {
 130  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1);
 131  1
     validateEvent(m_event1, this, COMP1, 5, -1, 0, DEFAULT_MOUSE_MODIFIERS,
 132   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 133   
 
 134  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 2);
 135  1
     validateEvent(m_event2, this, COMP2, 10, 2, 0, DEFAULT_MOUSE_MODIFIERS,
 136   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 137   
   }
 138   
 
 139   
   /**
 140   
    * Test the constructor.
 141   
    */
 142  1
   public void testMouseWheelEventData5() {
 143  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1, 1);
 144  1
     validateEvent(m_event1, this, COMP1, 5, -1, 1, DEFAULT_MOUSE_MODIFIERS,
 145   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 146   
 
 147  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 2, 2);
 148  1
     validateEvent(m_event2, this, COMP2, 10, 2, 2, DEFAULT_MOUSE_MODIFIERS,
 149   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 150   
   }
 151   
 
 152   
   /**
 153   
    * Test the constructor.
 154   
    */
 155  1
   public void testMouseWheelEventData6() {
 156  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1);
 157  1
     validateEvent(m_event1, this, COMP1, 5, -1, 1, MODIFIERS1,
 158   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 159   
 
 160  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 2, 2, MODIFIERS2);
 161  1
     validateEvent(m_event2, this, COMP2, 10, 2, 2, MODIFIERS2,
 162   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 163   
   }
 164   
 
 165   
   /**
 166   
    * Test the constructor.
 167   
    */
 168  1
   public void testMouseWheelEventData7() {
 169  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false);
 170  1
     validateEvent(m_event1, this, COMP1, 5, -1, 1, MODIFIERS1, false,
 171   
                   DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 172   
 
 173  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 2, 2, MODIFIERS2, true);
 174  1
     validateEvent(m_event2, this, COMP2, 10, 2, 2, MODIFIERS2, true,
 175   
                   DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 176   
   }
 177   
 
 178   
   /**
 179   
    * Test the constructor.
 180   
    */
 181  1
   public void testMouseWheelEventData8() {
 182  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false,
 183   
                                        1000);
 184  1
     validateEvent(m_event1, this, COMP1, 5, -1, 1, MODIFIERS1, false, 1000,
 185   
                   DEFAULT_POSITION, null);
 186   
 
 187  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 2, 2, MODIFIERS2, true,
 188   
                                        2000);
 189  1
     validateEvent(m_event2, this, COMP2, 10, 2, 2, MODIFIERS2, true, 2000,
 190   
                   DEFAULT_POSITION, null);
 191   
   }
 192   
 
 193   
   /**
 194   
    * Test the constructor.
 195   
    */
 196  1
   public void testMouseWheelEventData9() {
 197  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false,
 198   
                                        1000, PERCENT);
 199  1
     validateEvent(m_event1, this, COMP1, 5, -1, 1, MODIFIERS1, false, 1000,
 200   
                   PERCENT, null);
 201   
 
 202  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 2, 2, MODIFIERS2, true,
 203   
                                        2000, PERCENT);
 204  1
     validateEvent(m_event2, this, COMP2, 10, 2, 2, MODIFIERS2, true, 2000,
 205   
                   PERCENT, null);
 206   
   }
 207   
 
 208   
   /**
 209   
    * Test the constructor.
 210   
    */
 211  1
   public void testMouseWheelEventData10() {
 212  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false,
 213   
                                        1000, P1);
 214  1
     validateEvent(m_event1, this, COMP1, 5, -1, 1, MODIFIERS1, false, 1000,
 215   
                   CUSTOM, P1);
 216   
 
 217  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 2, 2, MODIFIERS2, true,
 218   
                                        2000, P2);
 219  1
     validateEvent(m_event2, this, COMP2, 10, 2, 2, MODIFIERS2, true, 2000,
 220   
                   CUSTOM, P2);
 221   
   }
 222   
 
 223   
   /**
 224   
    * Test the constructor.
 225   
    */
 226  1
   public void testMouseWheelEventData11() {
 227  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false,
 228   
                                        1000, PERCENT, P1);
 229  1
     validateEvent(m_event1, this, COMP1, 5, -1, 1, MODIFIERS1, false, 1000,
 230   
                   PERCENT, P1);
 231   
 
 232  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 2, 2, MODIFIERS2, true,
 233   
                                        2000, PERCENT, P2);
 234  1
     validateEvent(m_event2, this, COMP2, 10, 2, 2, MODIFIERS2, true, 2000,
 235   
                   PERCENT, P2);
 236   
   }
 237   
 
 238   
   /**
 239   
    * Test the equals.
 240   
    */
 241  1
   public void testEquals() {
 242  1
     m_event1 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false,
 243   
                                        1000, PERCENT, P1);
 244  1
     m_event2 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false,
 245   
                                        1000, PERCENT, P1);
 246  1
     assertTrue("Not equals:", m_event1.equals(m_event2));
 247  1
     assertTrue("Null equals:", !m_event1.equals(null));
 248  1
     assertTrue("Invalid class:", !m_event1.equals(new String()));
 249  1
     m_event2 = new MouseWheelEventData(this, COMP2, 5, -1, 1, MODIFIERS1, false,
 250   
                                        1000, PERCENT, P1);
 251  1
     assertTrue("Equals but Component different:", !m_event1.equals(m_event2));
 252  1
     m_event2 = new MouseWheelEventData(this, COMP1, 10, -1, 1, MODIFIERS1, false,
 253   
                                        1000, PERCENT, P1);
 254  1
     assertTrue("Equals but amount different:", !m_event1.equals(m_event2));
 255  1
     m_event2 = new MouseWheelEventData(this, COMP1, 5, 1, 1, MODIFIERS1, false,
 256   
                                        1000, PERCENT, P1);
 257  1
     assertTrue("Equals but rotation different:", !m_event1.equals(m_event2));
 258   
 
 259  1
     m_event2 = new MouseWheelEventData(this, COMP1, 5, -1, 0, MODIFIERS1, false,
 260   
                                        1000, PERCENT, P1);
 261  1
     assertTrue("Equals but Clicks different:", !m_event1.equals(m_event2));
 262  1
     m_event2 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS2, false,
 263   
                                        1000, PERCENT, P1);
 264  1
     assertTrue("Equals but Modifiers different:", !m_event1.equals(m_event2));
 265  1
     m_event2 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, true,
 266   
                                        1000, PERCENT, P1);
 267  1
     assertTrue("Equals but Popup different:", !m_event1.equals(m_event2));
 268  1
     m_event2 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false,
 269   
                                        1000, CUSTOM, P1);
 270  1
     assertTrue("Equals but Position different:", !m_event1.equals(m_event2));
 271  1
     m_event2 = new MouseWheelEventData(this, COMP1, 5, -1, 1, MODIFIERS1, false,
 272   
                                        1000, PERCENT, P2);
 273  1
     assertTrue("Equals but Reference different:", !m_event1.equals(m_event2));
 274  1
     m_event2 = new MouseWheelEventData(this, COMP2, 10, 1, 0, MODIFIERS2, true,
 275   
                                        1000, CUSTOM, P2);
 276  1
     assertTrue("Equals but All different:", !m_event1.equals(m_event2));
 277   
   }
 278   
 }
 279