1 26 package org.objectweb.util.explorer.core.menu; 27 28 import org.objectweb.util.explorer.core.menu.api.AcceleratorDescription; 29 import org.objectweb.util.explorer.core.menu.lib.BasicAcceleratorDescription; 30 31 import junit.framework.Assert; 32 import junit.framework.TestCase; 33 34 42 public class AcceleratorDescriptionTest 43 extends TestCase 44 { 45 46 47 53 protected AcceleratorDescription charOnly_,ctrlChar_,ctrlShiftChar_,all_; 54 55 protected char theChar_ = 'A', otherChar_ = 'B'; 56 57 63 69 72 protected void setUp() throws Exception { 73 charOnly_ = new BasicAcceleratorDescription(); 74 charOnly_.setAcceleratorCharacter(theChar_); 75 ctrlChar_ = new BasicAcceleratorDescription(); 76 ctrlChar_.setCtrlKey(true); 77 ctrlChar_.setAcceleratorCharacter(theChar_); 78 ctrlShiftChar_ = new BasicAcceleratorDescription(); 79 ctrlShiftChar_.setCtrlKey(true); 80 ctrlShiftChar_.setShiftKey(true); 81 ctrlShiftChar_.setAcceleratorCharacter(theChar_); 82 all_ = new BasicAcceleratorDescription(); 83 all_.setCtrlKey(true); 84 all_.setShiftKey(true); 85 all_.setAltKey(true); 86 all_.setMetaKey(true); 87 all_.setAcceleratorCharacter(theChar_); 88 } 89 90 96 99 public void testEqualsMethod(){ 100 AcceleratorDescription expected = null; 101 Assert.assertNotSame(expected,charOnly_); 102 Assert.assertEquals(ctrlChar_,ctrlChar_); 103 expected = new BasicAcceleratorDescription(); 104 expected.setAcceleratorCharacter(otherChar_); 105 Assert.assertNotSame(expected,charOnly_); 106 expected.setAcceleratorCharacter(theChar_); 107 Assert.assertEquals(expected,charOnly_); 108 expected.setCtrlKey(true); 109 Assert.assertEquals(expected,ctrlChar_); 110 Assert.assertNotSame(expected,ctrlShiftChar_); 111 expected.setShiftKey(true); 112 Assert.assertEquals(expected,ctrlShiftChar_); 113 expected.setAltKey(true); 114 expected.setMetaKey(true); 115 Assert.assertNotSame(expected,ctrlChar_); 116 Assert.assertEquals(expected,all_); 117 } 118 119 122 public void testToStringMethod(){ 123 String expected = "BasicAcceleratorDescription[value=" + theChar_ + "]"; 124 Assert.assertEquals(expected,charOnly_.toString()); 125 expected="BasicAcceleratorDescription[value=ctrl-" + theChar_ + "]"; 126 Assert.assertEquals(expected,ctrlChar_.toString()); 127 expected="BasicAcceleratorDescription[value=ctrl-shift-" + theChar_ + "]"; 128 Assert.assertEquals(expected,ctrlShiftChar_.toString()); 129 expected="BasicAcceleratorDescription[value=ctrl-alt-shift-meta-" + theChar_ + "]"; 130 Assert.assertEquals(expected,all_.toString()); 131 } 132 133 } 134 135 | Popular Tags |