Clover coverage report - JFCUnit Test Coverage
Coverage timestamp: Mon Dec 20 2004 23:38:10 MST
file stats: LOC: 113   Methods: 7
NCLOC: 58   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
JFCKeyStrokeT.java - 100% 100% 100%
coverage
 1   
 package junit.extensions.jfcunit.keyboard;
 2   
 
 3   
 import java.awt.event.KeyEvent;
 4   
 
 5   
 import junit.framework.TestCase;
 6   
 
 7   
 /**
 8   
  * <p>Title: class JFCKeyStrokeT</p>
 9   
  * <p>Description: Test the JFCKeyStroke.</p>
 10   
  * <p>Copyright: Copyright (c) 2003</p>
 11   
  * <p>Company: JFCUnit OpenSource probject.</p>
 12   
  * @author Kevin Wilson not attributable
 13   
  * @version 1.0
 14   
  */
 15   
 public class JFCKeyStrokeT
 16   
     extends TestCase {
 17   
 
 18   
   /**
 19   
    * KeyStroke to be tested.
 20   
    */
 21   
   private JFCKeyStroke m_jfcKeyStroke = null;
 22   
 
 23   
   /**
 24   
    * Constructor.
 25   
    * @param name Name of the test case.
 26   
    */
 27  4
   public JFCKeyStrokeT(final String name) {
 28  4
     super(name);
 29   
   }
 30   
 
 31   
   /**
 32   
    * Setup the test case.
 33   
    * @throws Exception may be thrown.
 34   
    */
 35  4
   protected void setUp() throws Exception {
 36  4
     super.setUp();
 37  4
     m_jfcKeyStroke = new JFCKeyStroke('x', 0, 0, false);
 38   
   }
 39   
 
 40   
   /**
 41   
    * Tear down the test case.
 42   
    * @throws Exception may be thrown.
 43   
    */
 44  4
   protected void tearDown() throws Exception {
 45  4
     m_jfcKeyStroke = null;
 46  4
     super.tearDown();
 47   
   }
 48   
 
 49   
   /**
 50   
    * Test the toString of the class.
 51   
    */
 52  1
   public void testToString() {
 53  1
     m_jfcKeyStroke = new JFCKeyStroke('A', 64, KeyEvent.SHIFT_MASK, true);
 54  1
     String expectedReturn = "Char:A Code:64 Mods:1 IsTyped:true";
 55  1
     String actualReturn = m_jfcKeyStroke.toString();
 56  1
     assertEquals("return value", expectedReturn, actualReturn);
 57   
 
 58  1
     m_jfcKeyStroke = new JFCKeyStroke((char) 1, 1, KeyEvent.CTRL_MASK, false);
 59  1
     expectedReturn = "<control A>";
 60  1
     actualReturn = m_jfcKeyStroke.toString();
 61  1
     assertEquals("return value", expectedReturn, actualReturn);
 62   
   }
 63   
 
 64   
   /**
 65   
    * Test the clone method of the keystroke.
 66   
    */
 67  1
   public void testClone() {
 68  1
     m_jfcKeyStroke = new JFCKeyStroke('A', 64, KeyEvent.SHIFT_MASK, true);
 69  1
     m_jfcKeyStroke = new JFCKeyStroke(m_jfcKeyStroke);
 70   
 
 71   
   }
 72   
 
 73   
   /**
 74   
    * Test the hashcode method of the keystroke.
 75   
    */
 76  1
   public void testHashCode() {
 77  1
     m_jfcKeyStroke = new JFCKeyStroke('A', 64, KeyEvent.SHIFT_MASK, true);
 78  1
     JFCKeyStroke jFCKeyStroke2 = new JFCKeyStroke('B', 66, KeyEvent.SHIFT_MASK, true);
 79  1
     int actualReturn = m_jfcKeyStroke.hashCode();
 80  1
     assertTrue("return value", 1 != actualReturn);
 81   
 
 82  1
     this.assertTrue("HashCode of different keys should be diferent",
 83   
                      m_jfcKeyStroke.hashCode() != jFCKeyStroke2.hashCode());
 84   
   }
 85   
 
 86   
   /**
 87   
    * Test the Equals method of the JFCKeyStroke.
 88   
    */
 89  1
   public void testEquals() {
 90  1
     Object o;
 91  1
     boolean expectedReturn;
 92  1
     boolean actualReturn;
 93   
 
 94   
 //     Test Null Object
 95  1
     o = null;
 96  1
     expectedReturn = false;
 97  1
     actualReturn = m_jfcKeyStroke.equals(o);
 98  1
     assertEquals("return value", expectedReturn, actualReturn);
 99   
 
 100   
 //     Test heterogenous objects
 101  1
     o = this;
 102  1
     expectedReturn = false;
 103  1
     actualReturn = m_jfcKeyStroke.equals(o);
 104  1
     assertEquals("return value", expectedReturn, actualReturn);
 105   
 
 106  1
     o = new JFCKeyStroke('a', 1, 0, true);
 107  1
     Object o2 = new JFCKeyStroke('a', 1, 0, true);
 108  1
     expectedReturn = true;
 109  1
     actualReturn = o2.equals(o);
 110  1
     assertEquals("return value", expectedReturn, actualReturn);
 111   
   }
 112   
 }
 113