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.assertFalse; |
25 |
|
import static org.testng.Assert.assertTrue; |
26 |
|
|
27 |
|
import java.io.File; |
28 |
|
|
29 |
|
import org.testng.annotations.AfterMethod; |
30 |
|
import org.testng.annotations.BeforeClass; |
31 |
|
import org.testng.annotations.BeforeMethod; |
32 |
|
import org.testng.annotations.DataProvider; |
33 |
|
import org.testng.annotations.Test; |
34 |
|
|
35 |
|
import jalview.bin.Cache; |
36 |
|
import jalview.bin.Jalview; |
37 |
|
import jalview.datamodel.AlignmentI; |
38 |
|
import jalview.datamodel.SequenceI; |
39 |
|
import jalview.gui.StructureViewer.ViewerType; |
40 |
|
import jalview.io.DataSourceType; |
41 |
|
import jalview.io.FileLoader; |
42 |
|
import jalview.structure.StructureImportSettings.TFType; |
43 |
|
import jalview.util.Platform; |
44 |
|
|
|
|
| 88.5% |
Uncovered Elements: 10 (87) |
Complexity: 16 |
Complexity Density: 0.24 |
|
45 |
|
public class AnnotationLabelsTest2 |
46 |
|
{ |
47 |
|
private static double scaling; |
48 |
|
|
|
|
| 75% |
Uncovered Elements: 2 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
49 |
1 |
@BeforeClass(alwaysRun = true)... |
50 |
|
public static void setUpBeforeClass() throws Exception |
51 |
|
{ |
52 |
1 |
if (Desktop.instance != null) |
53 |
0 |
Desktop.instance.closeAll_actionPerformed(null); |
54 |
|
|
55 |
1 |
setUpJvOptionPane(); |
56 |
|
|
57 |
|
|
58 |
|
|
59 |
1 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
60 |
1 |
Jalview.main(new String[] { "--nonews", "--nosplash", }); |
61 |
|
|
62 |
1 |
scaling = JvSwingUtilsTest.getScaling(Desktop.instance); |
63 |
|
} |
64 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
65 |
4 |
@AfterMethod(alwaysRun = true)... |
66 |
|
public void tearDown() |
67 |
|
{ |
68 |
4 |
if (Desktop.instance != null) |
69 |
4 |
Desktop.instance.closeAll_actionPerformed(null); |
70 |
|
} |
71 |
|
|
72 |
|
|
73 |
|
|
74 |
|
|
75 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
76 |
4 |
@BeforeMethod(alwaysRun = true)... |
77 |
|
public void setUp() |
78 |
|
{ |
79 |
4 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
80 |
4 |
Cache.applicationProperties.setProperty("SHOW_IDENTITY", |
81 |
|
Boolean.TRUE.toString()); |
82 |
|
|
83 |
|
} |
84 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
85 |
1 |
public static void setUpJvOptionPane()... |
86 |
|
{ |
87 |
1 |
JvOptionPane.setInteractiveMode(false); |
88 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
89 |
|
} |
90 |
|
|
|
|
| 92.9% |
Uncovered Elements: 2 (28) |
Complexity: 4 |
Complexity Density: 0.15 |
1PASS
|
|
91 |
2 |
@Test(... |
92 |
|
groups = |
93 |
|
{ "Functional", "testTask1" }, |
94 |
|
dataProvider = "openFilesWithIdWidthChanges") |
95 |
|
public void testIdWidthChanges(String alignmentFilename, boolean wrap, |
96 |
|
int idWidth1min, int idWidth1max, int manualWidth, |
97 |
|
String structureFilename, String paeFilename, |
98 |
|
boolean secondaryStructureView, TFType temperatureFactorType, |
99 |
|
ViewerType viewerType, int idWidth2min, int idWidth2max) |
100 |
|
{ |
101 |
2 |
AlignFrame af = new FileLoader() |
102 |
|
.LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE); |
103 |
|
|
104 |
2 |
try |
105 |
|
{ |
106 |
2 |
Thread.sleep(200); |
107 |
|
} catch (InterruptedException e) |
108 |
|
{ |
109 |
|
|
110 |
0 |
e.printStackTrace(); |
111 |
|
} |
112 |
2 |
AlignViewport av = af.getCurrentView(); |
113 |
|
|
114 |
2 |
int idWidth = 0; |
115 |
|
|
116 |
2 |
idWidth = av.getIdWidth(); |
117 |
2 |
assertTrue(idWidth > idWidth1min, |
118 |
|
"idWidth (" + idWidth + ") is not greater than " + idWidth1min); |
119 |
2 |
assertTrue(idWidth < idWidth1max, "idWidth (" + idWidth |
120 |
|
+ ") is not narrower than " + idWidth1max); |
121 |
|
|
122 |
|
|
123 |
2 |
if (wrap) |
124 |
|
{ |
125 |
1 |
af.setWrapFormat(true, false); |
126 |
1 |
idWidth = av.getIdWidth(); |
127 |
1 |
assertTrue(idWidth > idWidth1min, "After wrap idWidth (" + idWidth |
128 |
|
+ ") is not greater than " + idWidth1min); |
129 |
1 |
assertTrue(idWidth < idWidth1max, "After wrap idWidth (" + idWidth |
130 |
|
+ ") is not narrower than" + idWidth1max); |
131 |
|
} |
132 |
|
|
133 |
2 |
AlignmentI al = av.getAlignment(); |
134 |
2 |
SequenceI s = al.getSequenceAt(0); |
135 |
2 |
AlignmentPanel ap = af.alignPanel; |
136 |
|
|
137 |
2 |
File structureFile = new File(structureFilename); |
138 |
2 |
File paeFile = new File(paeFilename); |
139 |
|
|
140 |
2 |
StructureViewer sv = StructureChooser.openStructureFileForSequence(null, |
141 |
|
null, ap, s, false, structureFile.getAbsolutePath(), |
142 |
|
temperatureFactorType, paeFile.getAbsolutePath(), true, |
143 |
|
secondaryStructureView, false, viewerType); |
144 |
|
|
145 |
2 |
try |
146 |
|
{ |
147 |
2 |
Thread.sleep(200); |
148 |
|
} catch (InterruptedException e) |
149 |
|
{ |
150 |
|
|
151 |
0 |
e.printStackTrace(); |
152 |
|
} |
153 |
|
|
154 |
|
|
155 |
2 |
idWidth = av.getIdWidth(); |
156 |
2 |
assertTrue(idWidth >= idWidth2min, |
157 |
|
"idWidth (" + idWidth + ") is not greater than " + idWidth2min); |
158 |
2 |
assertTrue(idWidth <= idWidth2max, "idWidth (" + idWidth |
159 |
|
+ ") is not narrower than " + idWidth2max); |
160 |
|
} |
161 |
|
|
|
|
| 96% |
Uncovered Elements: 1 (25) |
Complexity: 2 |
Complexity Density: 0.08 |
1PASS
|
|
162 |
2 |
@Test(... |
163 |
|
groups = |
164 |
|
{ "Functional", "testTask1" }, |
165 |
|
dataProvider = "openFilesWithIdWidthChanges") |
166 |
|
public void testIdWidthNoChanges(String alignmentFilename, boolean wrap, |
167 |
|
int idWidth1min, int idWidth1max, int manualWidth, |
168 |
|
String structureFilename, String paeFilename, |
169 |
|
boolean secondaryStructureView, TFType temperatureFactorType, |
170 |
|
ViewerType viewerType, int idWidth2min, int idWidth2max) |
171 |
|
{ |
172 |
2 |
AlignFrame af = new FileLoader() |
173 |
|
.LoadFileWaitTillLoaded(alignmentFilename, DataSourceType.FILE); |
174 |
2 |
try |
175 |
|
{ |
176 |
2 |
Thread.sleep(200); |
177 |
|
} catch (InterruptedException e) |
178 |
|
{ |
179 |
|
|
180 |
0 |
e.printStackTrace(); |
181 |
|
} |
182 |
2 |
AlignViewport av = af.getCurrentView(); |
183 |
|
|
184 |
2 |
int idWidth = 0; |
185 |
2 |
idWidth = av.getIdWidth(); |
186 |
2 |
assertTrue(idWidth > idWidth1min, |
187 |
|
"idWidth (" + idWidth + ") is not greater than " + idWidth1min); |
188 |
2 |
assertTrue(idWidth < idWidth1max, |
189 |
|
"idWidth (" + idWidth + ") is not narrower than" + idWidth1max); |
190 |
|
|
191 |
2 |
AlignmentI al = av.getAlignment(); |
192 |
2 |
SequenceI s = al.getSequenceAt(0); |
193 |
2 |
AlignmentPanel ap = af.alignPanel; |
194 |
|
|
195 |
|
|
196 |
2 |
av.setIdWidth(manualWidth); |
197 |
2 |
ap.validateAnnotationDimensions(false); |
198 |
2 |
ap.paintAlignment(true, false); |
199 |
2 |
ap.getIdPanel().getIdCanvas().setManuallyAdjusted(true); |
200 |
|
|
201 |
2 |
idWidth = av.getIdWidth(); |
202 |
2 |
assertEquals(idWidth, manualWidth, |
203 |
|
"idWidth is not set to the manually set width " + manualWidth); |
204 |
|
|
205 |
2 |
File structureFile = new File(structureFilename); |
206 |
2 |
File paeFile = new File(paeFilename); |
207 |
|
|
208 |
2 |
StructureViewer sv = StructureChooser.openStructureFileForSequence(null, |
209 |
|
null, ap, s, false, structureFile.getAbsolutePath(), |
210 |
|
temperatureFactorType, paeFile.getAbsolutePath(), false, |
211 |
|
secondaryStructureView, false, viewerType); |
212 |
|
|
213 |
2 |
idWidth = ap.getIdPanel().getWidth(); |
214 |
2 |
idWidth = av.getIdWidth(); |
215 |
2 |
assertEquals(idWidth, manualWidth, |
216 |
|
"idWidth is not set to the manually set width " + manualWidth |
217 |
|
+ " after adding structure annotations"); |
218 |
2 |
assertFalse(idWidth > idWidth2min, |
219 |
|
"idWidth (" + idWidth + ") is greater than " + idWidth2min); |
220 |
|
} |
221 |
|
|
|
|
| 63.6% |
Uncovered Elements: 4 (11) |
Complexity: 4 |
Complexity Density: 0.8 |
|
222 |
2 |
@DataProvider(name = "openFilesWithIdWidthChanges")... |
223 |
|
public Object[][] openFilesWithIdWidthChanges() |
224 |
|
{ |
225 |
|
|
226 |
|
|
227 |
|
|
228 |
|
|
229 |
|
|
230 |
|
|
231 |
|
|
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
236 |
|
|
237 |
|
|
238 |
|
|
239 |
2 |
int idWidth2min = scaling == 1.0 ? 114 : 108; |
240 |
2 |
int idWidth2max = scaling == 1.0 ? 117 : 114; |
241 |
2 |
if (Platform.isMac()) |
242 |
|
{ |
243 |
0 |
idWidth2max = 122; |
244 |
|
} |
245 |
|
|
246 |
2 |
return new Object[][] { |
247 |
|
|
248 |
|
|
249 |
|
|
250 |
|
{ "./test/files/annotation_label_width/sample.a2m", false, 50, 70, |
251 |
|
100, |
252 |
|
"./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb", |
253 |
|
"./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json", |
254 |
|
true, TFType.PLDDT, null, idWidth2min, idWidth2max }, |
255 |
|
{ "./test/files/annotation_label_width/sample.a2m", true, 50, 70, |
256 |
|
100, |
257 |
|
"./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3.pdb", |
258 |
|
"./examples/test_fab41.result/test_fab41_unrelaxed_rank_1_model_3_scores.json", |
259 |
|
true, TFType.PLDDT, null, idWidth2min, idWidth2max }, |
260 |
|
|
261 |
|
|
262 |
|
}; |
263 |
|
} |
264 |
|
|
265 |
|
} |