1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.util; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertFalse; |
25 |
|
import static org.testng.Assert.assertNull; |
26 |
|
import static org.testng.Assert.assertTrue; |
27 |
|
|
28 |
|
import jalview.gui.JvOptionPane; |
29 |
|
|
30 |
|
import java.awt.Button; |
31 |
|
import java.awt.Toolkit; |
32 |
|
import java.awt.event.InputEvent; |
33 |
|
import java.awt.event.MouseEvent; |
34 |
|
|
35 |
|
import org.testng.annotations.BeforeClass; |
36 |
|
import org.testng.annotations.Test; |
37 |
|
|
|
|
| 66% |
Uncovered Elements: 17 (50) |
Complexity: 6 |
Complexity Density: 0.14 |
|
38 |
|
public class PlatformTest |
39 |
|
{ |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
41 |
1 |
@BeforeClass(alwaysRun = true)... |
42 |
|
public void setUpJvOptionPane() |
43 |
|
{ |
44 |
1 |
JvOptionPane.setInteractiveMode(false); |
45 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
46 |
|
} |
47 |
|
|
48 |
|
Button b = new Button(); |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
|
|
| 19% |
Uncovered Elements: 17 (21) |
Complexity: 2 |
Complexity Density: 0.11 |
1PASS
|
|
54 |
1 |
@Test(groups = "Functional")... |
55 |
|
public void testIsControlDown_mac() |
56 |
|
{ |
57 |
1 |
String toolkit = Toolkit.getDefaultToolkit().getClass().getName(); |
58 |
1 |
if ("sun.awt.X11.XToolkit".equals(toolkit)) |
59 |
|
{ |
60 |
|
|
61 |
|
|
62 |
|
|
63 |
|
|
64 |
1 |
return; |
65 |
|
} |
66 |
|
|
67 |
0 |
int clickCount = 1; |
68 |
0 |
boolean isPopupTrigger = false; |
69 |
0 |
int buttonNo = MouseEvent.BUTTON1; |
70 |
0 |
boolean mac = true; |
71 |
|
|
72 |
0 |
int mods = 0; |
73 |
|
|
74 |
0 |
assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, |
75 |
|
0, 0, clickCount, isPopupTrigger, buttonNo), mac)); |
76 |
|
|
77 |
0 |
mods = InputEvent.CTRL_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; |
78 |
0 |
assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, |
79 |
|
0, 0, clickCount, isPopupTrigger, buttonNo), mac)); |
80 |
|
|
81 |
0 |
mods = InputEvent.META_DOWN_MASK | InputEvent.BUTTON1_DOWN_MASK; |
82 |
0 |
assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, |
83 |
|
0, 0, clickCount, isPopupTrigger, buttonNo), mac)); |
84 |
|
|
85 |
0 |
isPopupTrigger = true; |
86 |
0 |
assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, |
87 |
|
0, 0, clickCount, isPopupTrigger, buttonNo), mac)); |
88 |
|
|
89 |
0 |
isPopupTrigger = false; |
90 |
0 |
buttonNo = MouseEvent.BUTTON2; |
91 |
0 |
mods = 0; |
92 |
0 |
assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, |
93 |
|
0, 0, clickCount, isPopupTrigger, buttonNo), mac)); |
94 |
|
} |
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
100 |
1 |
@Test(groups = "Functional")... |
101 |
|
public void testIsControlDown_notMac() |
102 |
|
{ |
103 |
1 |
int clickCount = 1; |
104 |
1 |
boolean isPopupTrigger = false; |
105 |
1 |
int buttonNo = MouseEvent.BUTTON1; |
106 |
1 |
boolean mac = false; |
107 |
|
|
108 |
1 |
int mods = 0; |
109 |
|
|
110 |
1 |
assertFalse(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, |
111 |
|
0, 0, clickCount, isPopupTrigger, buttonNo), mac)); |
112 |
|
|
113 |
1 |
mods = InputEvent.CTRL_DOWN_MASK; |
114 |
1 |
assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, |
115 |
|
0, 0, clickCount, isPopupTrigger, buttonNo), mac)); |
116 |
|
|
117 |
1 |
mods = InputEvent.CTRL_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK |
118 |
|
| InputEvent.ALT_DOWN_MASK; |
119 |
1 |
clickCount = 2; |
120 |
1 |
buttonNo = 2; |
121 |
1 |
isPopupTrigger = true; |
122 |
1 |
assertTrue(Platform.isControlDown(new MouseEvent(b, 0, 0L, mods, 0, 0, |
123 |
|
0, 0, clickCount, isPopupTrigger, buttonNo), mac)); |
124 |
|
} |
125 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
126 |
1 |
@Test(groups = "Functional")... |
127 |
|
public void testPathEquals() |
128 |
|
{ |
129 |
1 |
assertTrue(Platform.pathEquals(null, null)); |
130 |
1 |
assertFalse(Platform.pathEquals(null, "apath")); |
131 |
1 |
assertFalse(Platform.pathEquals("apath", null)); |
132 |
1 |
assertFalse(Platform.pathEquals("apath", "APATH")); |
133 |
1 |
assertTrue(Platform.pathEquals("apath", "apath")); |
134 |
1 |
assertTrue(Platform.pathEquals("apath/a/b", "apath\\a\\b")); |
135 |
|
} |
136 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
137 |
1 |
@Test(groups = "Functional")... |
138 |
|
public void testEscapeBackslashes() |
139 |
|
{ |
140 |
1 |
assertNull(Platform.escapeBackslashes(null)); |
141 |
1 |
assertEquals(Platform.escapeBackslashes("hello world"), "hello world"); |
142 |
1 |
assertEquals(Platform.escapeBackslashes("hello\\world"), |
143 |
|
"hello\\\\world"); |
144 |
|
} |
145 |
|
} |