Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 284   Methods: 17
NCLOC: 164   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
MouseEventDataT.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   
 import java.awt.event.MouseEvent;
 8   
 
 9   
 import javax.swing.JButton;
 10   
 
 11   
 /**
 12   
  * Data container class that holds all the data necessary for jfcUnit to fire mouse events.
 13   
  *
 14   
  * @author <a href="mailto:vraravam@thoughtworks.com">Vijay Aravamudhan : ThoughtWorks Inc.</a>
 15   
  */
 16   
 public class MouseEventDataT
 17   
     extends MouseEventDataBC {
 18   
   /**
 19   
    * Event data to be validated.
 20   
    */
 21   
   private MouseEventData m_event1 = null;
 22   
 
 23   
   /**
 24   
    * Second event data to be validated.
 25   
    */
 26   
   private MouseEventData 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  14
   public MouseEventDataT(final String name) {
 44  14
     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  14
   protected void tearDown() throws Exception {
 53  14
     super.tearDown();
 54  14
     m_event1 = null;
 55  14
     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 clicks mouse clicks.
 66   
    * @param modifiers Modifiers to be used.
 67   
    * @param popup Popup.
 68   
    * @param sleepTime sleep duration.
 69   
    * @param position locatio of mouse.
 70   
    * @param ref Reference location.
 71   
    */
 72  24
   protected void validateEvent(
 73   
       final MouseEventData event,
 74   
       final JFCTestCase tc,
 75   
       final Component comp,
 76   
       final int clicks,
 77   
       final int modifiers,
 78   
       final boolean popup,
 79   
       final long sleepTime,
 80   
       final int position,
 81   
       final Point ref) {
 82  24
     super.validateEvent(event, tc, comp, clicks, modifiers, popup, sleepTime,
 83   
                         position, ref);
 84  24
     assertSameOrNull("Source:", comp, event.getSource());
 85   
   }
 86   
 
 87   
   /**
 88   
    * Test the constructor.
 89   
    */
 90  1
   public void testMouseEventData1() {
 91  1
     m_event1 = new MouseEventData();
 92  1
     assertEquals("Should be invalid", false, m_event1.isValid());
 93  1
     assertEquals("Prepare result:", false, m_event1.prepareComponent());
 94   
   }
 95   
 
 96   
   /**
 97   
    * Test the constructor.
 98   
    */
 99  1
   public void testMouseEventData1a() {
 100  1
     m_event1 = new MouseEventData(this, COMP1);
 101  1
     validateEvent(m_event1, this, COMP1, 1, DEFAULT_MOUSE_MODIFIERS,
 102   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 103   
 
 104  1
     m_event2 = new MouseEventData(this, COMP2);
 105  1
     validateEvent(m_event2, this, COMP2, 1, DEFAULT_MOUSE_MODIFIERS,
 106   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 107   
   }
 108   
 
 109   
   /**
 110   
    * Test the constructor.
 111   
    */
 112  1
   public void testMouseEventData1b() {
 113  1
     m_event1 = new MouseEventData(this, COMP1, 1000L);
 114  1
     validateEvent(m_event1, this, COMP1, 1, DEFAULT_MOUSE_MODIFIERS,
 115   
                   DEFAULT_ISPOPUPTRIGGER, 1000, DEFAULT_POSITION, null);
 116   
 
 117  1
     m_event2 = new MouseEventData(this, COMP2, 2000L);
 118  1
     validateEvent(m_event2, this, COMP2, 1, DEFAULT_MOUSE_MODIFIERS,
 119   
                   DEFAULT_ISPOPUPTRIGGER, 2000, DEFAULT_POSITION, null);
 120   
   }
 121   
 
 122   
   /**
 123   
    * Test the constructor.
 124   
    */
 125  1
   public void testMouseEventData2() {
 126  1
     m_event1 = new MouseEventData(this, COMP1, 1);
 127  1
     validateEvent(m_event1, this, COMP1, 1, DEFAULT_MOUSE_MODIFIERS,
 128   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 129   
 
 130  1
     m_event2 = new MouseEventData(this, COMP2, 2);
 131  1
     validateEvent(m_event2, this, COMP2, 2, DEFAULT_MOUSE_MODIFIERS,
 132   
                   DEFAULT_ISPOPUPTRIGGER, DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 133   
   }
 134   
 
 135   
   /**
 136   
    * Test the constructor.
 137   
    */
 138  1
   public void testMouseEventData2b() {
 139  1
     m_event1 = new MouseEventData(this, COMP1, 1, MODIFIERS1);
 140  1
     validateEvent(m_event1, this, COMP1, 1, MODIFIERS1, DEFAULT_ISPOPUPTRIGGER,
 141   
                   DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 142   
 
 143  1
     m_event2 = new MouseEventData(this, COMP2, 2, MODIFIERS2);
 144  1
     validateEvent(m_event2, this, COMP2, 2, MODIFIERS2, DEFAULT_ISPOPUPTRIGGER,
 145   
                   DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 146   
   }
 147   
 
 148   
   /**
 149   
    * Test the constructor.
 150   
    */
 151  1
   public void testMouseEventData2a() {
 152  1
     m_event1 = new MouseEventData(this, COMP1, 1, false);
 153  1
     validateEvent(m_event1, this, COMP1, 1, DEFAULT_MOUSE_MODIFIERS, false,
 154   
                   DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 155   
 
 156  1
     m_event2 = new MouseEventData(this, COMP2, 2, true);
 157  1
     validateEvent(m_event2, this, COMP2, 2, MouseEvent.BUTTON3_MASK, true,
 158   
                   DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 159   
   }
 160   
 
 161   
   /**
 162   
    * Test the constructor.
 163   
    */
 164  1
   public void testMouseEventData3() {
 165  1
     m_event1 = new MouseEventData(this, COMP1, 1, 500L);
 166  1
     validateEvent(m_event1, this, COMP1, 1, DEFAULT_MOUSE_MODIFIERS,
 167   
                   DEFAULT_ISPOPUPTRIGGER, 500, DEFAULT_POSITION, null);
 168   
 
 169  1
     m_event2 = new MouseEventData(this, COMP2, 2, 1500L);
 170  1
     validateEvent(m_event2, this, COMP2, 2, DEFAULT_MOUSE_MODIFIERS,
 171   
                   DEFAULT_ISPOPUPTRIGGER, 1500, DEFAULT_POSITION, null);
 172   
   }
 173   
 
 174   
   /**
 175   
    * Test the constructor.
 176   
    */
 177  1
   public void testMouseEventData3a() {
 178  1
     m_event1 = new MouseEventData(this, COMP1, 1, false, 500);
 179  1
     validateEvent(m_event1, this, COMP1, 1, DEFAULT_MOUSE_MODIFIERS, false, 500,
 180   
                   DEFAULT_POSITION, null);
 181   
 
 182  1
     m_event2 = new MouseEventData(this, COMP2, 2, true, 1500);
 183  1
     validateEvent(m_event2, this, COMP2, 2, MouseEvent.BUTTON3_MASK, true, 1500,
 184   
                   DEFAULT_POSITION, null);
 185   
   }
 186   
 
 187   
   /**
 188   
    * Test the constructor.
 189   
    */
 190  1
   public void testMouseEventData4a() {
 191  1
     m_event1 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true);
 192  1
     validateEvent(m_event1, this, COMP1, 1, MODIFIERS1, true, DEFAULT_SLEEPTIME,
 193   
                   DEFAULT_POSITION, null);
 194   
 
 195  1
     m_event2 = new MouseEventData(this, COMP2, 2, MODIFIERS2, false);
 196  1
     validateEvent(m_event2, this, COMP2, 2, MODIFIERS2, false,
 197   
                   DEFAULT_SLEEPTIME, DEFAULT_POSITION, null);
 198   
   }
 199   
 
 200   
   /**
 201   
    * Test the constructor.
 202   
    */
 203  1
   public void testMouseEventData4() {
 204  1
     m_event1 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true, 500);
 205  1
     validateEvent(m_event1, this, COMP1, 1, MODIFIERS1, true, 500,
 206   
                   DEFAULT_POSITION, null);
 207   
 
 208  1
     m_event2 = new MouseEventData(this, COMP2, 2, MODIFIERS2, false, 1500);
 209  1
     validateEvent(m_event2, this, COMP2, 2, MODIFIERS2, false, 1500,
 210   
                   DEFAULT_POSITION, null);
 211   
   }
 212   
 
 213   
   /**
 214   
    * Test the constructor.
 215   
    */
 216  1
   public void testMouseEventData5() {
 217  1
     m_event1 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true, 500, P1);
 218  1
     validateEvent(m_event1, this, COMP1, 1, MODIFIERS1, true, 500, CUSTOM, P1);
 219   
 
 220  1
     m_event2 = new MouseEventData(this, COMP2, 2, MODIFIERS2, false, 1500, P2);
 221  1
     validateEvent(m_event2, this, COMP2, 2, MODIFIERS2, false, 1500, CUSTOM, P2);
 222   
   }
 223   
 
 224   
   /**
 225   
    * Test the constructor.
 226   
    */
 227  1
   public void testMouseEventData6() {
 228  1
     m_event1 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true, 500, WEST);
 229  1
     validateEvent(m_event1, this, COMP1, 1, MODIFIERS1, true, 500, WEST, null);
 230   
 
 231  1
     m_event2 = new MouseEventData(this, COMP2, 2, MODIFIERS2, false, 1500,
 232   
                                   NORTH_WEST);
 233  1
     validateEvent(m_event2, this, COMP2, 2, MODIFIERS2, false, 1500, NORTH_WEST, null);
 234   
   }
 235   
 
 236   
   /**
 237   
    * Test the constructor.
 238   
    */
 239  1
   public void testMouseEventData7() {
 240  1
     m_event1 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true, 500, CUSTOM,
 241   
                                   P1);
 242  1
     validateEvent(m_event1, this, COMP1, 1, MODIFIERS1, true, 500, CUSTOM, P1);
 243   
 
 244  1
     m_event2 = new MouseEventData(this, COMP2, 2, MODIFIERS2, false, 1500,
 245   
                                   PERCENT, P2);
 246  1
     validateEvent(m_event2, this, COMP2, 2, MODIFIERS2, false, 1500, PERCENT,
 247   
                   P2);
 248   
   }
 249   
 
 250   
   /**
 251   
    * Test the equals.
 252   
    */
 253  1
   public void testEquals() {
 254  1
     m_event1 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true, 500, CUSTOM,
 255   
                                   P1);
 256  1
     m_event2 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true, 500, CUSTOM,
 257   
                                   P1);
 258  1
     assertTrue("Not equals:", m_event1.equals(m_event2));
 259  1
     assertTrue("Null equals:", !m_event1.equals(null));
 260  1
     assertTrue("Invalid class:", !m_event1.equals(new String()));
 261  1
     m_event2 = new MouseEventData(this, COMP2, 1, MODIFIERS1, true, 500, CUSTOM,
 262   
                                   P1);
 263  1
     assertTrue("Equals but Component different:", !m_event1.equals(m_event2));
 264  1
     m_event2 = new MouseEventData(this, COMP1, 2, MODIFIERS1, true, 500, CUSTOM,
 265   
                                   P1);
 266  1
     assertTrue("Equals but Clicks different:", !m_event1.equals(m_event2));
 267  1
     m_event2 = new MouseEventData(this, COMP1, 1, MODIFIERS2, true, 500, CUSTOM,
 268   
                                   P1);
 269  1
     assertTrue("Equals but Modifiers different:", !m_event1.equals(m_event2));
 270  1
     m_event2 = new MouseEventData(this, COMP1, 1, MODIFIERS1, false, 500,
 271   
                                   CUSTOM, P1);
 272  1
     assertTrue("Equals but Popup different:", !m_event1.equals(m_event2));
 273  1
     m_event2 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true, 500,
 274   
                                   PERCENT, P1);
 275  1
     assertTrue("Equals but Position different:", !m_event1.equals(m_event2));
 276  1
     m_event2 = new MouseEventData(this, COMP1, 1, MODIFIERS1, true, 500, CUSTOM,
 277   
                                   P2);
 278  1
     assertTrue("Equals but Reference different:", !m_event1.equals(m_event2));
 279  1
     m_event2 = new MouseEventData(this, COMP2, 2, MODIFIERS2, false, 1500,
 280   
                                   PERCENT, P2);
 281  1
     assertTrue("Equals but All different:", !m_event1.equals(m_event2));
 282   
   }
 283   
 }
 284