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.Assert.assertEquals; |
24 |
|
import static org.testng.Assert.assertNotEquals; |
25 |
|
|
26 |
|
import java.awt.Dimension; |
27 |
|
import java.awt.Font; |
28 |
|
import java.awt.FontMetrics; |
29 |
|
import java.lang.reflect.InvocationTargetException; |
30 |
|
|
31 |
|
import javax.swing.SwingUtilities; |
32 |
|
|
33 |
|
import org.testng.annotations.BeforeMethod; |
34 |
|
import org.testng.annotations.Test; |
35 |
|
|
36 |
|
import jalview.api.AlignViewportI; |
37 |
|
import jalview.bin.Cache; |
38 |
|
import jalview.bin.Jalview; |
39 |
|
import jalview.datamodel.AlignmentAnnotation; |
40 |
|
import jalview.datamodel.SequenceI; |
41 |
|
import jalview.io.DataSourceType; |
42 |
|
import jalview.io.FileLoader; |
43 |
|
import jalview.viewmodel.ViewportRanges; |
44 |
|
|
|
|
| 88.1% |
Uncovered Elements: 12 (101) |
Complexity: 9 |
Complexity Density: 0.1 |
|
45 |
|
public class AlignmentPanelTest |
46 |
|
{ |
47 |
|
AlignFrame af; |
48 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
|
49 |
4 |
@BeforeMethod(alwaysRun = true)... |
50 |
|
public void setUp() throws InvocationTargetException, InterruptedException |
51 |
|
{ |
52 |
4 |
Jalview.main(new String[] { "-nonews", "-props", |
53 |
|
"test/jalview/testProps.jvprops" }); |
54 |
|
|
55 |
4 |
Cache.applicationProperties.setProperty("SHOW_IDENTITY", |
56 |
|
Boolean.TRUE.toString()); |
57 |
4 |
af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa", |
58 |
|
DataSourceType.FILE); |
59 |
|
|
60 |
|
|
61 |
|
|
62 |
|
|
63 |
4 |
SwingUtilities.invokeAndWait(new Runnable() { |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
64 |
4 |
@Override... |
65 |
|
public void run() { |
66 |
4 |
af.repaint(); |
67 |
|
}}); |
68 |
|
|
69 |
|
|
70 |
|
|
71 |
|
|
72 |
4 |
do |
73 |
|
{ |
74 |
4 |
try |
75 |
|
{ |
76 |
4 |
Thread.sleep(50); |
77 |
|
} catch (InterruptedException x) |
78 |
|
{ |
79 |
|
} |
80 |
4 |
} while (af.getViewport().getCalcManager().isWorking()); |
81 |
|
} |
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
87 |
1 |
@Test(groups = "Functional")... |
88 |
|
public void testSetScrollValues() |
89 |
|
{ |
90 |
1 |
ViewportRanges ranges = af.getViewport().getRanges(); |
91 |
1 |
af.alignPanel.setScrollValues(0, 0); |
92 |
|
|
93 |
1 |
int oldres = ranges.getEndRes(); |
94 |
1 |
af.alignPanel.setScrollValues(-1, 5); |
95 |
|
|
96 |
|
|
97 |
1 |
assertEquals(ranges.getEndRes(), oldres); |
98 |
|
|
99 |
1 |
af.alignPanel.setScrollValues(0, 5); |
100 |
|
|
101 |
|
|
102 |
1 |
assertEquals(ranges.getEndRes(), oldres); |
103 |
|
|
104 |
1 |
af.alignPanel.setScrollValues(5, 5); |
105 |
|
|
106 |
1 |
assertEquals(ranges.getEndRes(), oldres + 5); |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
1 |
int scrollpos = 60; |
111 |
1 |
af.getViewport().hideColumns(30, 50); |
112 |
1 |
af.alignPanel.setScrollValues(scrollpos, 5); |
113 |
1 |
assertEquals(ranges.getEndRes(), oldres + scrollpos); |
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
1 |
scrollpos = 40; |
120 |
1 |
af.getViewport().showAllHiddenColumns(); |
121 |
1 |
af.getViewport().hideColumns(30, 50); |
122 |
1 |
af.alignPanel.setScrollValues(scrollpos, 5); |
123 |
1 |
assertEquals(ranges.getEndRes(), oldres + scrollpos); |
124 |
|
|
125 |
|
|
126 |
|
|
127 |
1 |
scrollpos = 130; |
128 |
1 |
af.getViewport().showAllHiddenColumns(); |
129 |
1 |
af.alignPanel.setScrollValues(scrollpos, 5); |
130 |
1 |
assertEquals(ranges.getEndRes(), af.getViewport() |
131 |
|
.getAlignment().getWidth() - 1); |
132 |
|
|
133 |
|
|
134 |
|
|
135 |
|
|
136 |
|
|
137 |
1 |
af.getViewport().hideColumns(30, 50); |
138 |
1 |
af.alignPanel.setScrollValues(scrollpos, 5); |
139 |
1 |
assertEquals(ranges.getEndRes(), af.getViewport() |
140 |
|
.getAlignment().getWidth() - 1 - 21); |
141 |
|
|
142 |
|
} |
143 |
|
|
144 |
|
|
145 |
|
|
146 |
|
|
147 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
148 |
1 |
@Test(groups = "Functional")... |
149 |
|
public void testUpdateLayout_endRes() |
150 |
|
{ |
151 |
|
|
152 |
1 |
ViewportRanges ranges = af.getViewport().getRanges(); |
153 |
1 |
int endres = ranges.getEndRes(); |
154 |
|
|
155 |
|
|
156 |
1 |
af.alignPanel.getAlignViewport().setWrapAlignment(true); |
157 |
1 |
af.alignPanel.updateLayout(); |
158 |
|
|
159 |
|
|
160 |
1 |
assertNotEquals(ranges.getEndRes(), endres); |
161 |
|
|
162 |
|
|
163 |
1 |
af.alignPanel.getAlignViewport().setWrapAlignment(false); |
164 |
1 |
af.alignPanel.updateLayout(); |
165 |
|
|
166 |
|
|
167 |
1 |
assertEquals(ranges.getEndRes(), endres); |
168 |
|
} |
169 |
|
|
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
174 |
1 |
@Test(groups = "Functional")... |
175 |
|
public void testCalculateIdWidth_noArgs() |
176 |
|
{ |
177 |
1 |
AlignViewportI av = af.alignPanel.getAlignViewport(); |
178 |
1 |
av.setShowJVSuffix(true); |
179 |
1 |
av.setFont(new Font("Courier", Font.PLAIN, 15), true); |
180 |
|
|
181 |
1 |
av.setIdWidth(0); |
182 |
1 |
Dimension d = af.alignPanel.calculateIdWidth(); |
183 |
1 |
assertEquals(d.width, 0); |
184 |
1 |
assertEquals(d.height, 0); |
185 |
|
|
186 |
1 |
av.setIdWidth(99); |
187 |
1 |
d = af.alignPanel.calculateIdWidth(); |
188 |
1 |
assertEquals(d.width, 99); |
189 |
1 |
assertEquals(d.height, 0); |
190 |
|
|
191 |
|
|
192 |
|
|
193 |
|
|
194 |
1 |
av.setIdWidth(-1); |
195 |
1 |
d = af.alignPanel.calculateIdWidth(); |
196 |
1 |
assertEquals(d.width, 166); |
197 |
1 |
assertEquals(d.height, 12); |
198 |
1 |
assertEquals(d.width, av.getIdWidth()); |
199 |
|
} |
200 |
|
|
201 |
|
|
202 |
|
|
203 |
|
|
204 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 1 |
Complexity Density: 0.04 |
1PASS
|
|
205 |
1 |
@Test(groups = "Functional")... |
206 |
|
public void testCalculateIdWidth_withMaxWidth() |
207 |
|
{ |
208 |
1 |
AlignViewportI av = af.alignPanel.getAlignViewport(); |
209 |
1 |
av.setShowJVSuffix(true); |
210 |
1 |
av.setFont(new Font("Courier", Font.PLAIN, 15), true); |
211 |
1 |
av.setShowAnnotation(false); |
212 |
1 |
av.setIdWidth(18); |
213 |
|
|
214 |
|
|
215 |
|
|
216 |
|
|
217 |
1 |
Dimension d = af.alignPanel.calculateIdWidth(2000); |
218 |
1 |
assertEquals(d.width, 166); |
219 |
1 |
assertEquals(d.height, 12); |
220 |
1 |
assertEquals(av.getIdWidth(), 18); |
221 |
|
|
222 |
|
|
223 |
|
|
224 |
|
|
225 |
1 |
SequenceI seq = af.viewport.getAlignment() |
226 |
|
.findSequenceMatch("Q93Z60_ARATH")[0]; |
227 |
1 |
seq.setName(seq.getName() + "MMMMM"); |
228 |
1 |
d = af.alignPanel.calculateIdWidth(2000); |
229 |
1 |
assertEquals(d.width, 211); |
230 |
1 |
assertEquals(d.height, 12); |
231 |
1 |
assertEquals(av.getIdWidth(), 18); |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
1 |
AlignmentAnnotation aa = av.getAlignment().getAlignmentAnnotation()[0]; |
238 |
1 |
aa.label = "THIS IS A VERY LONG LABEL INDEED"; |
239 |
1 |
FontMetrics fmfor = af.alignPanel |
240 |
|
.getFontMetrics(af.alignPanel.getAlabels().getFont()); |
241 |
|
|
242 |
1 |
int expwidth = 4 + fmfor.stringWidth(aa.label); |
243 |
1 |
d = af.alignPanel.calculateIdWidth(2000); |
244 |
1 |
assertEquals(d.width, expwidth); |
245 |
1 |
assertEquals(d.height, 12); |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
|
251 |
1 |
d = af.alignPanel.calculateIdWidth(213); |
252 |
1 |
assertEquals(d.width, 217); |
253 |
1 |
assertEquals(d.height, 12); |
254 |
|
} |
255 |
|
|
|
|
| 0% |
Uncovered Elements: 10 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
256 |
0 |
@Test(groups = { "Functional", "Not-bamboo" })... |
257 |
|
public void testGetVisibleWidth() |
258 |
|
{ |
259 |
|
|
260 |
|
|
261 |
|
|
262 |
0 |
int w = af.alignPanel.getVisibleIdWidth(true); |
263 |
0 |
assertEquals(w, af.alignPanel.getIdPanel().getWidth()); |
264 |
0 |
assertEquals(w, 115); |
265 |
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
0 |
Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.FALSE.toString()); |
271 |
0 |
Cache.removeProperty("FIGURE_FIXEDIDWIDTH"); |
272 |
0 |
assertEquals(w, af.alignPanel.getVisibleIdWidth(false)); |
273 |
|
|
274 |
|
|
275 |
|
|
276 |
|
|
277 |
0 |
Cache.setProperty("FIGURE_FIXEDIDWIDTH", "120"); |
278 |
0 |
assertEquals(124, af.alignPanel.getVisibleIdWidth(false)); |
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
0 |
Cache.setProperty("FIGURE_AUTOIDWIDTH", Boolean.TRUE.toString()); |
284 |
0 |
assertEquals(115, af.alignPanel.getVisibleIdWidth(false)); |
285 |
|
} |
286 |
|
} |