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.assertSame; |
25 |
|
import static org.testng.AssertJUnit.assertTrue; |
26 |
|
|
27 |
|
import jalview.datamodel.Alignment; |
28 |
|
import jalview.datamodel.Sequence; |
29 |
|
import jalview.datamodel.SequenceI; |
30 |
|
import jalview.viewmodel.AlignmentViewport; |
31 |
|
|
32 |
|
import java.awt.Component; |
33 |
|
import java.util.List; |
34 |
|
import java.util.Map; |
35 |
|
|
36 |
|
import javax.swing.JPanel; |
37 |
|
|
38 |
|
import org.testng.annotations.AfterMethod; |
39 |
|
import org.testng.annotations.BeforeClass; |
40 |
|
import org.testng.annotations.BeforeMethod; |
41 |
|
import org.testng.annotations.Test; |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (55) |
Complexity: 6 |
Complexity Density: 0.12 |
|
43 |
|
public class PaintRefresherTest |
44 |
|
{ |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
46 |
1 |
@BeforeClass(alwaysRun = true)... |
47 |
|
public void setUpJvOptionPane() |
48 |
|
{ |
49 |
1 |
JvOptionPane.setInteractiveMode(false); |
50 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
51 |
|
} |
52 |
|
|
53 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
54 |
3 |
@BeforeMethod(alwaysRun = true)... |
55 |
|
public void setUp() |
56 |
|
{ |
57 |
3 |
PaintRefresher.components.clear(); |
58 |
|
} |
59 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
60 |
3 |
@AfterMethod(alwaysRun = true)... |
61 |
|
public void tearDown() |
62 |
|
{ |
63 |
3 |
PaintRefresher.components.clear(); |
64 |
|
} |
65 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
66 |
1 |
@Test(groups = { "Functional" })... |
67 |
|
public void testRegister() |
68 |
|
{ |
69 |
1 |
JPanel jp = new JPanel(); |
70 |
1 |
JPanel jp2 = new JPanel(); |
71 |
1 |
JPanel jp3 = new JPanel(); |
72 |
1 |
JPanel jp4 = new JPanel(); |
73 |
1 |
PaintRefresher.Register(jp, "22"); |
74 |
1 |
PaintRefresher.Register(jp, "22"); |
75 |
1 |
PaintRefresher.Register(jp2, "22"); |
76 |
1 |
PaintRefresher.Register(jp3, "33"); |
77 |
1 |
PaintRefresher.Register(jp3, "44"); |
78 |
1 |
PaintRefresher.Register(jp4, "44"); |
79 |
|
|
80 |
1 |
Map<String, List<Component>> registered = PaintRefresher.components; |
81 |
1 |
assertEquals(3, registered.size()); |
82 |
1 |
assertEquals(2, registered.get("22").size()); |
83 |
1 |
assertEquals(1, registered.get("33").size()); |
84 |
1 |
assertEquals(2, registered.get("44").size()); |
85 |
1 |
assertTrue(registered.get("22").contains(jp)); |
86 |
1 |
assertTrue(registered.get("22").contains(jp2)); |
87 |
1 |
assertTrue(registered.get("33").contains(jp3)); |
88 |
1 |
assertTrue(registered.get("44").contains(jp3)); |
89 |
1 |
assertTrue(registered.get("44").contains(jp4)); |
90 |
|
} |
91 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
92 |
1 |
@Test(groups = { "Functional" })... |
93 |
|
public void testRemoveComponent() |
94 |
|
{ |
95 |
1 |
Map<String, List<Component>> registered = PaintRefresher.components; |
96 |
|
|
97 |
|
|
98 |
1 |
JPanel jp = new JPanel(); |
99 |
1 |
JPanel jp2 = new JPanel(); |
100 |
1 |
PaintRefresher.RemoveComponent(jp); |
101 |
1 |
assertTrue(registered.isEmpty()); |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
106 |
1 |
PaintRefresher.Register(jp, "11"); |
107 |
1 |
PaintRefresher.RemoveComponent(jp); |
108 |
1 |
assertTrue(registered.isEmpty()); |
109 |
|
|
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
114 |
1 |
PaintRefresher.Register(jp, "11"); |
115 |
1 |
PaintRefresher.Register(jp, "22"); |
116 |
1 |
PaintRefresher.Register(jp2, "22"); |
117 |
1 |
PaintRefresher.RemoveComponent(jp); |
118 |
|
|
119 |
1 |
assertEquals(1, registered.size()); |
120 |
1 |
assertEquals(1, registered.get("22").size()); |
121 |
1 |
assertTrue(registered.get("22").contains(jp2)); |
122 |
|
} |
123 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
124 |
1 |
@Test(groups = { "Functional" })... |
125 |
|
public void testGetAssociatedPanels() |
126 |
|
{ |
127 |
1 |
SequenceI[] seqs = new SequenceI[] { new Sequence("", "ABC") }; |
128 |
1 |
Alignment al = new Alignment(seqs); |
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
|
|
135 |
1 |
AlignmentViewport av = new AlignViewport(al); |
136 |
1 |
AlignFrame af = new AlignFrame(al, 4, 1); |
137 |
1 |
AlignmentPanel ap1 = af.alignPanel; |
138 |
1 |
AlignmentPanel[] panels = PaintRefresher |
139 |
|
.getAssociatedPanels(av.getSequenceSetId()); |
140 |
1 |
assertEquals(1, panels.length); |
141 |
1 |
assertSame(ap1, panels[0]); |
142 |
|
|
143 |
1 |
panels = PaintRefresher.getAssociatedPanels(av.getSequenceSetId() + 1); |
144 |
1 |
assertEquals(0, panels.length); |
145 |
|
} |
146 |
|
} |