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 java.awt.Font; |
24 |
|
import java.awt.FontMetrics; |
25 |
|
|
26 |
|
import org.testng.annotations.BeforeMethod; |
27 |
|
import org.testng.annotations.Test; |
28 |
|
import static org.testng.Assert.assertEquals; |
29 |
|
import static org.testng.Assert.assertFalse; |
30 |
|
import static org.testng.Assert.assertNotNull; |
31 |
|
import static org.testng.Assert.assertNull; |
32 |
|
import static org.testng.Assert.assertTrue; |
33 |
|
|
34 |
|
|
35 |
|
import jalview.bin.Cache; |
36 |
|
import jalview.datamodel.AlignmentI; |
37 |
|
import jalview.datamodel.SearchResults; |
38 |
|
import jalview.datamodel.SearchResultsI; |
39 |
|
import jalview.io.DataSourceType; |
40 |
|
import jalview.io.DataSourceType; |
41 |
|
import jalview.io.FileLoader; |
42 |
|
|
43 |
|
import junit.extensions.PA; |
44 |
|
|
|
|
| 86.9% |
Uncovered Elements: 22 (168) |
Complexity: 7 |
Complexity Density: 0.04 |
|
45 |
|
public class SeqCanvasTest |
46 |
|
{ |
47 |
|
private AlignFrame af; |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (79) |
Complexity: 1 |
Complexity Density: 0.01 |
1PASS
|
|
53 |
1 |
@Test(groups = "Functional")... |
54 |
|
public void testCalculateWrappedGeometry_noAnnotations() |
55 |
|
{ |
56 |
1 |
AlignViewport av = af.getViewport(); |
57 |
1 |
AlignmentI al = av.getAlignment(); |
58 |
1 |
assertEquals(al.getWidth(), 157); |
59 |
1 |
assertEquals(al.getHeight(), 15); |
60 |
1 |
av.getRanges().setStartEndSeq(0, 14); |
61 |
|
|
62 |
1 |
SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas; |
63 |
|
|
64 |
1 |
av.setWrapAlignment(true); |
65 |
1 |
av.setFont(new Font("SansSerif", Font.PLAIN, 14), true); |
66 |
1 |
int charHeight = av.getCharHeight(); |
67 |
1 |
int charWidth = av.getCharWidth(); |
68 |
1 |
assertEquals(charHeight, 17); |
69 |
1 |
assertEquals(charWidth, 12); |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
1 |
av.setShowAnnotation(false); |
75 |
1 |
av.setScaleAboveWrapped(true); |
76 |
1 |
av.setScaleLeftWrapped(true); |
77 |
1 |
av.setScaleRightWrapped(true); |
78 |
1 |
FontMetrics fm = testee.getFontMetrics(av.getFont()); |
79 |
1 |
int labelWidth = fm.stringWidth("000") + charWidth; |
80 |
1 |
assertEquals(labelWidth, 39); |
81 |
|
|
82 |
|
|
83 |
|
|
84 |
|
|
85 |
|
|
86 |
1 |
int canvasWidth = 400; |
87 |
1 |
int canvasHeight = 300; |
88 |
1 |
int residueColumns = (canvasWidth - 2 * labelWidth) / charWidth; |
89 |
1 |
int wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
90 |
1 |
assertEquals(wrappedWidth, residueColumns); |
91 |
1 |
assertEquals(PA.getValue(testee, "labelWidthWest"), labelWidth); |
92 |
1 |
assertEquals(PA.getValue(testee, "labelWidthEast"), labelWidth); |
93 |
1 |
assertEquals(PA.getValue(testee, "wrappedSpaceAboveAlignment"), |
94 |
|
2 * charHeight); |
95 |
1 |
int repeatingHeight = (int) PA.getValue(testee, "wrappedRepeatHeightPx"); |
96 |
1 |
assertEquals(repeatingHeight, charHeight * (2 + al.getHeight())); |
97 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 1); |
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
1 |
canvasHeight = charHeight * (17 * 2 + 3); |
105 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
106 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 3); |
107 |
|
|
108 |
|
|
109 |
|
|
110 |
|
|
111 |
|
|
112 |
1 |
canvasHeight -= 1; |
113 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
114 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 2); |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
119 |
1 |
av.setScaleAboveWrapped(false); |
120 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
121 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 3); |
122 |
|
|
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
1 |
canvasHeight = charHeight * (16 * 2 + 2) - 1; |
128 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
129 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 2); |
130 |
|
|
131 |
|
|
132 |
|
|
133 |
|
|
134 |
1 |
canvasWidth = 2 * labelWidth + 20 * charWidth; |
135 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
136 |
|
canvasHeight); |
137 |
1 |
assertEquals(wrappedWidth, 20); |
138 |
|
|
139 |
|
|
140 |
|
|
141 |
|
|
142 |
1 |
canvasWidth -= 1; |
143 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
144 |
|
canvasHeight); |
145 |
1 |
assertEquals(wrappedWidth, 19); |
146 |
|
|
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
|
151 |
1 |
av.setScaleLeftWrapped(false); |
152 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
153 |
|
canvasHeight); |
154 |
1 |
assertEquals(wrappedWidth, 23); |
155 |
|
|
156 |
|
|
157 |
|
|
158 |
|
|
159 |
1 |
canvasWidth += 9; |
160 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
161 |
|
canvasHeight); |
162 |
1 |
assertEquals(wrappedWidth, 23); |
163 |
1 |
canvasWidth += 1; |
164 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
165 |
|
canvasHeight); |
166 |
1 |
assertEquals(wrappedWidth, 24); |
167 |
|
|
168 |
|
|
169 |
|
|
170 |
|
|
171 |
1 |
av.setScaleRightWrapped(false); |
172 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
173 |
|
canvasHeight); |
174 |
1 |
assertEquals(wrappedWidth, 27); |
175 |
|
|
176 |
|
|
177 |
|
|
178 |
|
|
179 |
1 |
canvasWidth += 8; |
180 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
181 |
|
canvasHeight); |
182 |
1 |
assertEquals(wrappedWidth, 27); |
183 |
1 |
canvasWidth += 1; |
184 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
185 |
|
canvasHeight); |
186 |
1 |
assertEquals(wrappedWidth, 28); |
187 |
|
|
188 |
|
|
189 |
|
|
190 |
|
|
191 |
1 |
av.setScaleLeftWrapped(true); |
192 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
193 |
|
canvasHeight); |
194 |
1 |
assertEquals(wrappedWidth, 24); |
195 |
|
|
196 |
|
|
197 |
|
|
198 |
|
|
199 |
1 |
canvasWidth += 2; |
200 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
201 |
|
canvasHeight); |
202 |
1 |
assertEquals(wrappedWidth, 24); |
203 |
1 |
canvasWidth += 1; |
204 |
1 |
wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, |
205 |
|
canvasHeight); |
206 |
1 |
assertEquals(wrappedWidth, 25); |
207 |
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
1 |
av.setScaleLeftWrapped(false); |
212 |
1 |
canvasWidth = al.getWidth() * charWidth; |
213 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
214 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 1); |
215 |
|
} |
216 |
|
|
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (46) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
221 |
1 |
@Test(groups = "Functional")... |
222 |
|
public void testCalculateWrappedGeometry_withAnnotations() |
223 |
|
{ |
224 |
1 |
AlignViewport av = af.getViewport(); |
225 |
1 |
AlignmentI al = av.getAlignment(); |
226 |
1 |
assertEquals(al.getWidth(), 157); |
227 |
1 |
assertEquals(al.getHeight(), 15); |
228 |
|
|
229 |
1 |
av.setWrapAlignment(true); |
230 |
1 |
av.getRanges().setStartEndSeq(0, 14); |
231 |
1 |
av.setFont(new Font("SansSerif", Font.PLAIN, 14), true); |
232 |
1 |
int charHeight = av.getCharHeight(); |
233 |
1 |
int charWidth = av.getCharWidth(); |
234 |
1 |
assertEquals(charHeight, 17); |
235 |
1 |
assertEquals(charWidth, 12); |
236 |
|
|
237 |
1 |
SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas; |
238 |
|
|
239 |
|
|
240 |
|
|
241 |
|
|
242 |
1 |
av.setShowAnnotation(true); |
243 |
1 |
av.setScaleAboveWrapped(true); |
244 |
1 |
av.setScaleLeftWrapped(true); |
245 |
1 |
av.setScaleRightWrapped(true); |
246 |
1 |
FontMetrics fm = testee.getFontMetrics(av.getFont()); |
247 |
1 |
int labelWidth = fm.stringWidth("000") + charWidth; |
248 |
1 |
assertEquals(labelWidth, 39); |
249 |
1 |
int annotationHeight = testee.getAnnotationHeight(); |
250 |
|
|
251 |
|
|
252 |
|
|
253 |
|
|
254 |
|
|
255 |
1 |
int canvasWidth = 400; |
256 |
1 |
int canvasHeight = 300; |
257 |
1 |
int residueColumns = (canvasWidth - 2 * labelWidth) / charWidth; |
258 |
1 |
int wrappedWidth = testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
259 |
1 |
assertEquals(wrappedWidth, residueColumns); |
260 |
1 |
assertEquals(PA.getValue(testee, "labelWidthWest"), labelWidth); |
261 |
1 |
assertEquals(PA.getValue(testee, "labelWidthEast"), labelWidth); |
262 |
1 |
assertEquals(PA.getValue(testee, "wrappedSpaceAboveAlignment"), |
263 |
|
2 * charHeight); |
264 |
1 |
int repeatingHeight = (int) PA.getValue(testee, "wrappedRepeatHeightPx"); |
265 |
1 |
assertEquals(repeatingHeight, charHeight * (2 + al.getHeight()) |
266 |
|
+ SeqCanvas.SEQS_ANNOTATION_GAP + annotationHeight); |
267 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 1); |
268 |
|
|
269 |
|
|
270 |
|
|
271 |
|
|
272 |
|
|
273 |
|
|
274 |
1 |
canvasHeight = charHeight * (17 * 2 + 3) |
275 |
|
+ 2 * (annotationHeight + SeqCanvas.SEQS_ANNOTATION_GAP); |
276 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
277 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 3); |
278 |
|
|
279 |
|
|
280 |
|
|
281 |
|
|
282 |
|
|
283 |
1 |
canvasHeight -= 1; |
284 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
285 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 2); |
286 |
|
|
287 |
|
|
288 |
|
|
289 |
|
|
290 |
1 |
av.setScaleAboveWrapped(false); |
291 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
292 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 3); |
293 |
|
|
294 |
|
|
295 |
|
|
296 |
|
|
297 |
|
|
298 |
1 |
canvasHeight = charHeight * (16 * 2 + 2) |
299 |
|
+ 2 * (annotationHeight + SeqCanvas.SEQS_ANNOTATION_GAP) - 1; |
300 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
301 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 2); |
302 |
|
|
303 |
|
|
304 |
|
|
305 |
|
|
306 |
1 |
canvasHeight += 1; |
307 |
1 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
308 |
1 |
assertEquals(PA.getValue(testee, "wrappedVisibleWidths"), 3); |
309 |
|
} |
310 |
|
|
311 |
|
|
312 |
|
|
313 |
|
|
314 |
|
|
315 |
|
|
316 |
|
|
|
|
| 0% |
Uncovered Elements: 20 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
317 |
0 |
@Test(groups = "Functional_Failing")... |
318 |
|
public void testCalculateWrappedGeometry_fromScrolled() |
319 |
|
{ |
320 |
0 |
AlignViewport av = af.getViewport(); |
321 |
0 |
AlignmentI al = av.getAlignment(); |
322 |
0 |
assertEquals(al.getWidth(), 157); |
323 |
0 |
assertEquals(al.getHeight(), 15); |
324 |
0 |
av.getRanges().setStartEndSeq(0, 3); |
325 |
0 |
av.setFont(new Font("SansSerif", Font.PLAIN, 14), true); |
326 |
0 |
av.setWrapAlignment(true); |
327 |
0 |
av.setShowAnnotation(false); |
328 |
0 |
av.setScaleAboveWrapped(true); |
329 |
|
|
330 |
0 |
SeqCanvas testee = af.alignPanel.getSeqPanel().seqCanvas; |
331 |
|
|
332 |
0 |
int charHeight = av.getCharHeight(); |
333 |
0 |
int charWidth = av.getCharWidth(); |
334 |
0 |
assertEquals(charHeight, 17); |
335 |
0 |
assertEquals(charWidth, 12); |
336 |
|
|
337 |
0 |
int canvasWidth = 400; |
338 |
0 |
int canvasHeight = 300; |
339 |
0 |
testee.calculateWrappedGeometry(canvasWidth, canvasHeight); |
340 |
|
|
341 |
0 |
assertEquals(av.getRanges().getEndSeq(), 3); |
342 |
0 |
int repeatingHeight = (int) PA.getValue(testee, |
343 |
|
"wrappedRepeatHeightPx"); |
344 |
0 |
assertEquals(repeatingHeight, charHeight * (2 + al.getHeight())); |
345 |
|
} |
346 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
|
347 |
3 |
@BeforeMethod(alwaysRun = true)... |
348 |
|
public void setUp() |
349 |
|
{ |
350 |
3 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
351 |
3 |
Cache.applicationProperties.setProperty("SHOW_IDENTITY", |
352 |
|
Boolean.TRUE.toString()); |
353 |
3 |
af = new FileLoader().LoadFileWaitTillLoaded("examples/uniref50.fa", |
354 |
|
DataSourceType.FILE); |
355 |
|
|
356 |
|
|
357 |
|
|
358 |
|
|
359 |
3 |
do |
360 |
|
{ |
361 |
3 |
try |
362 |
|
{ |
363 |
3 |
Thread.sleep(50); |
364 |
|
} catch (InterruptedException x) |
365 |
|
{ |
366 |
|
} |
367 |
3 |
} while (af.getViewport().getCalcManager().isWorking()); |
368 |
|
} |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
369 |
1 |
@Test(groups = "Functional")... |
370 |
|
public void testClear_HighlightAndSelection() |
371 |
|
{ |
372 |
1 |
AlignViewport av = af.getViewport(); |
373 |
1 |
SearchResultsI highlight = new SearchResults(); |
374 |
1 |
highlight.addResult( |
375 |
|
av.getAlignment().getSequenceAt(1).getDatasetSequence(), 50, |
376 |
|
80); |
377 |
1 |
af.alignPanel.highlightSearchResults(highlight); |
378 |
1 |
af.avc.markHighlightedColumns(false, false, false); |
379 |
1 |
assertNotNull(av.getSearchResults(), |
380 |
|
"No highlight was created on alignment"); |
381 |
1 |
assertFalse(av.getColumnSelection().isEmpty(), |
382 |
|
"No selection was created from highlight"); |
383 |
1 |
af.deselectAllSequenceMenuItem_actionPerformed(null); |
384 |
1 |
assertTrue(av.getColumnSelection().isEmpty(), |
385 |
|
"No Selection should be present after deselecting all."); |
386 |
1 |
assertNull(av.getSearchResults(), |
387 |
|
"No higlighted search results should be present after deselecting all."); |
388 |
|
} |
389 |
|
} |