EMMA Coverage Report (generated Sat Oct 08 11:41:37 CEST 2011)
[all classes][net.sf.jomic.tools]

COVERAGE SUMMARY FOR SOURCE FILE [UiToolsTest.java]

nameclass, %method, %block, %line, %
UiToolsTest.java100% (1/1)100% (7/7)88%  (82/93)95%  (21/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class UiToolsTest100% (1/1)100% (7/7)88%  (82/93)95%  (21/22)
testKeyStrokeToString (String): void 100% (1/1)69%  (18/26)83%  (4.1/5)
<static initializer> 100% (1/1)80%  (12/15)80%  (0.8/1)
UiToolsTest (): void 100% (1/1)100% (3/3)100% (1/1)
setUp (): void 100% (1/1)100% (8/8)100% (4/4)
tearDown (): void 100% (1/1)100% (6/6)100% (3/3)
testGetKeyCode (): void 100% (1/1)100% (25/25)100% (5/5)
testKeyStrokeToString (): void 100% (1/1)100% (10/10)100% (4/4)

1// Jomic - a viewer for comic book archives.
2// Copyright (C) 2004-2011 Thomas Aglassinger
3//
4// This program is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program.  If not, see <http://www.gnu.org/licenses/>.
16package net.sf.jomic.tools;
17 
18import java.awt.event.KeyEvent;
19 
20import javax.swing.KeyStroke;
21 
22import junit.framework.TestCase;
23 
24/**
25 *  TestCase for UiTools.
26 *
27 * @author    Thomas Aglassinger
28 */
29public class UiToolsTest extends TestCase
30{
31    private UiTools uiTools;
32 
33    protected void setUp()
34        throws Exception {
35        super.setUp();
36        TestTools.instance();
37        uiTools = UiTools.instance();
38    }
39 
40    public void testGetKeyCode() {
41        assertEquals("A", uiTools.getKeyText(KeyEvent.VK_A));
42        assertEquals("SHIFT", uiTools.getKeyText(KeyEvent.VK_SHIFT));
43        assertEquals("NUMPAD3", uiTools.getKeyText(KeyEvent.VK_NUMPAD3));
44        assertEquals("unknown(0x12345678)", uiTools.getKeyText(0x12345678));
45    }
46 
47    public void testKeyStrokeToString() {
48        testKeyStrokeToString("typed A");
49        testKeyStrokeToString("pressed SPACE");
50        testKeyStrokeToString("released SPACE");
51        // TODO: Add test cases like this: testKeyStrokeToString("alt pressed A");
52        // However, currently this fails because it turns into "alt button2 pressed A".
53    }
54 
55    protected void tearDown()
56        throws Exception {
57        uiTools = null;
58        super.tearDown();
59    }
60 
61    private void testKeyStrokeToString(String keyText) {
62        assert keyText != null;
63        KeyStroke stroke = KeyStroke.getKeyStroke(keyText);
64 
65        assert stroke != null;
66        assertEquals(keyText, uiTools.keyStrokeToString(stroke));
67    }
68}

[all classes][net.sf.jomic.tools]
EMMA 2.0.4217 (C) Vladimir Roubtsov