KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > util > explorer > core > menu > AcceleratorDescriptionTest


1 /*====================================================================
2
3 Objectweb Explorer Framework
4 Copyright (C) 2000-2004 INRIA - USTL - LIFL - GOAL
5 Contact: openccm@objectweb.org
6
7 This library is free software; you can redistribute it and/or
8 modify it under the terms of the GNU Lesser General Public
9 License as published by the Free Software Foundation; either
10 version 2.1 of the License, or any later version.
11
12 This library is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public
18 License along with this library; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 USA
21
22 Initial developer(s): Jerome Moroy, Philippe Merle.
23 Contributor(s): ______________________________________.
24
25 ====================================================================*/

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 /**
35  *
36  *
37  * @author <a HREF="mailto:Jerome.Moroy@lifl.fr">Jérôme Moroy</a>,
38  * <a HREF="mailto:Philippe.Merle@lifl.fr">Philippe Merle</a>.
39  *
40  * @version 0.1
41  */

42 public class AcceleratorDescriptionTest
43      extends TestCase
44 {
45
46
47     //==================================================================
48
//
49
// Internal States.
50
//
51
// ==================================================================
52

53     protected AcceleratorDescription charOnly_,ctrlChar_,ctrlShiftChar_,all_;
54     
55     protected char theChar_ = 'A', otherChar_ = 'B';
56     
57     // ==================================================================
58
//
59
// Constructors.
60
//
61
// ==================================================================
62

63     // ==================================================================
64
//
65
// Internal method.
66
//
67
// ==================================================================
68

69     /*
70      * @see TestCase#setUp()
71      */

72     protected void setUp() throws Exception JavaDoc {
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     // ==================================================================
91
//
92
// Public methods.
93
//
94
// ==================================================================
95

96     /**
97      * Checks if two definitions of AcceleratorDefinition are considered as equal.
98      */

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     /**
120      * Checks the String representation of a
121      */

122     public void testToStringMethod(){
123         String JavaDoc 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