1
|
|
package abbot.editor.widgets;
|
2
|
|
|
3
|
|
import java.awt.event.KeyEvent;
|
4
|
|
import javax.swing.JLabel;
|
5
|
|
import java.io.*;
|
6
|
|
import java.util.*;
|
7
|
|
|
8
|
|
import junit.framework.*;
|
9
|
|
import junit.extensions.abbot.*;
|
10
|
|
|
11
|
|
import abbot.i18n.Strings;
|
12
|
|
|
13
|
|
public class MnemonicTest extends TestCase {
|
14
|
|
|
15
|
1
|
public void testGetMnemonic() throws Exception {
|
16
|
1
|
Properties p = new Properties();
|
17
|
1
|
p.setProperty("MNEMONIC_\u00d6", "O");
|
18
|
1
|
p.store(new FileOutputStream("build/test-classes/abbot/editor/widgets/mnemonics.properties"), "test");
|
19
|
0
|
Strings.addBundle("abbot.editor.widgets.mnemonics");
|
20
|
0
|
Object[][] strings = {
|
21
|
|
{ "None", "None",
|
22
|
|
new Integer(KeyEvent.VK_UNDEFINED), new Integer(-1) },
|
23
|
|
{ "&File", "File",
|
24
|
|
new Integer(KeyEvent.VK_F), new Integer(0) },
|
25
|
|
{ "&lower", "lower",
|
26
|
|
new Integer(KeyEvent.VK_L), new Integer(0) },
|
27
|
|
{ "Last&", "Last&",
|
28
|
|
new Integer(KeyEvent.VK_UNDEFINED), new Integer(-1) },
|
29
|
|
{ "&TooMan&y", "TooMan&y",
|
30
|
|
new Integer(KeyEvent.VK_T), new Integer(0) },
|
31
|
|
{ "About &Al", "About Al",
|
32
|
|
new Integer(KeyEvent.VK_A), new Integer(6) },
|
33
|
|
{ "Rock && Roll", "Rock & Roll",
|
34
|
|
new Integer(KeyEvent.VK_UNDEFINED), new Integer(-1) },
|
35
|
|
{ "&Rock && Roll", "Rock & Roll",
|
36
|
|
new Integer(KeyEvent.VK_R), new Integer(0) },
|
37
|
|
{ "Rock && &Roll", "Rock & Roll",
|
38
|
|
new Integer(KeyEvent.VK_R), new Integer(7) },
|
39
|
|
{ "Rock & Roll", "Rock & Roll",
|
40
|
|
new Integer(KeyEvent.VK_UNDEFINED), new Integer(-1) },
|
41
|
|
{ "Sample '&' &character", "Sample '&' character",
|
42
|
|
new Integer(KeyEvent.VK_C), new Integer(11) },
|
43
|
|
{ "Chara&cteristic '&'", "Characteristic '&'",
|
44
|
|
new Integer(KeyEvent.VK_C), new Integer(5) },
|
45
|
|
|
46
|
|
{ "Unicode &\u00d6", "Unicode \u00d6",
|
47
|
|
new Integer(KeyEvent.VK_O), new Integer(8) },
|
48
|
|
|
49
|
|
{ "Symbol&=", "Symbol=",
|
50
|
|
new Integer(KeyEvent.VK_EQUALS), new Integer(6) },
|
51
|
|
};
|
52
|
0
|
for (int i=0;i < strings.length;i++) {
|
53
|
0
|
String str = (String)strings[i][0];
|
54
|
0
|
Mnemonic mnemonic = Mnemonic.getMnemonic(str);
|
55
|
0
|
assertEquals("Incorrect label for '" + str + "'",
|
56
|
|
strings[i][1], mnemonic.text);
|
57
|
0
|
assertEquals("Incorrect mnemonic keycode for '" + str + "'",
|
58
|
|
strings[i][2], new Integer(mnemonic.keycode));
|
59
|
0
|
assertEquals("Incorrect display index for '" + str + "'",
|
60
|
|
strings[i][3], new Integer(mnemonic.index));
|
61
|
|
}
|
62
|
|
}
|
63
|
|
|
64
|
|
|
65
|
1
|
public MnemonicTest(String name) { super(name); }
|
66
|
|
|
67
|
|
|
68
|
0
|
public static void main(String[] args) {
|
69
|
0
|
TestHelper.runTests(args, MnemonicTest.class);
|
70
|
|
}
|
71
|
|
}
|
72
|
|
|