1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
|
26 |
|
import javax.swing.JScrollBar; |
27 |
|
|
28 |
|
import org.testng.annotations.BeforeClass; |
29 |
|
import org.testng.annotations.Test; |
30 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (28) |
Complexity: 6 |
Complexity Density: 0.27 |
|
31 |
|
public class JvSwingUtilsTest |
32 |
|
{ |
33 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
34 |
1 |
@BeforeClass(alwaysRun = true)... |
35 |
|
public void setUpJvOptionPane() |
36 |
|
{ |
37 |
1 |
JvOptionPane.setInteractiveMode(false); |
38 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
39 |
|
} |
40 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
41 |
1 |
@Test(groups = { "Functional" })... |
42 |
|
public void testGetScrollBarProportion() |
43 |
|
{ |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
1 |
JScrollBar sb = new JScrollBar(0, 125, 50, 0, 450); |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
1 |
assertEquals(0.25f, JvSwingUtils.getScrollBarProportion(sb), 0.001f); |
54 |
|
} |
55 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
56 |
1 |
@Test(groups = { "Functional" })... |
57 |
|
public void testGetScrollValueForProportion() |
58 |
|
{ |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
1 |
JScrollBar sb = new JScrollBar(0, 125, 50, 0, 450); |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
1 |
assertEquals(125, JvSwingUtils.getScrollValueForProportion(sb, 0.25f)); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0.11 |
1PASS
|
|
75 |
1 |
@Test(groups = { "Functional" })... |
76 |
|
public void testWrapTooltip_shortText() |
77 |
|
{ |
78 |
1 |
String tip = "hello world"; |
79 |
1 |
assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); |
80 |
1 |
assertEquals("<html>" + tip + "</html>", |
81 |
|
JvSwingUtils.wrapTooltip(true, tip)); |
82 |
|
|
83 |
1 |
tip = "012345678901234567890123456789012345678901234567890123456789"; |
84 |
1 |
assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); |
85 |
1 |
assertEquals("<html>" + tip + "</html>", |
86 |
|
JvSwingUtils.wrapTooltip(true, tip)); |
87 |
|
|
88 |
1 |
tip = "0123456789012345678901234567890123456789012345678901234567890"; |
89 |
1 |
assertFalse(tip.equals(JvSwingUtils.wrapTooltip(false, tip))); |
90 |
1 |
assertFalse(("<html>" + tip + "</html>").equals(JvSwingUtils |
91 |
|
.wrapTooltip(true, tip))); |
92 |
|
} |
93 |
|
|
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
99 |
1 |
@Test(groups = { "Functional" })... |
100 |
|
public void testWrapTooltip_multilineShortText() |
101 |
|
{ |
102 |
1 |
String tip = "Now is the winter of our discontent<br>Made glorious summer by this sun of York"; |
103 |
1 |
assertEquals(tip, JvSwingUtils.wrapTooltip(false, tip)); |
104 |
1 |
assertEquals("<html>" + tip + "</html>", |
105 |
|
JvSwingUtils.wrapTooltip(true, tip)); |
106 |
|
} |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
112 |
1 |
@Test(groups = { "Functional" })... |
113 |
|
public void testWrapTooltip_longText() |
114 |
|
{ |
115 |
1 |
String tip = "Now is the winter of our discontent made glorious summer by this sun of York"; |
116 |
1 |
String expected = "<style> div.ttip {width:350px;white-space:pre-wrap;padding:2px;overflow-wrap:break-word;}</style>" |
117 |
|
+ "<div class=\"ttip\">" + tip + " </div>"; |
118 |
1 |
assertEquals("<html>" + expected + "</html>", |
119 |
|
JvSwingUtils.wrapTooltip(true, tip)); |
120 |
1 |
assertEquals(expected, JvSwingUtils.wrapTooltip(false, tip)); |
121 |
|
} |
122 |
|
} |