| 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 |
|
import static org.testng.AssertJUnit.assertTrue; |
| 26 |
|
|
| 27 |
|
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; |
| 28 |
|
import jalview.bin.Cache; |
| 29 |
|
import jalview.datamodel.AlignmentAnnotation; |
| 30 |
|
import jalview.datamodel.AlignmentI; |
| 31 |
|
import jalview.datamodel.Annotation; |
| 32 |
|
import jalview.datamodel.SequenceGroup; |
| 33 |
|
import jalview.datamodel.SequenceI; |
| 34 |
|
import jalview.io.DataSourceType; |
| 35 |
|
import jalview.io.FileFormat; |
| 36 |
|
import jalview.io.FormatAdapter; |
| 37 |
|
import jalview.util.MessageManager; |
| 38 |
|
|
| 39 |
|
import java.awt.BorderLayout; |
| 40 |
|
import java.awt.Checkbox; |
| 41 |
|
import java.awt.Component; |
| 42 |
|
import java.awt.Container; |
| 43 |
|
import java.awt.FlowLayout; |
| 44 |
|
import java.awt.event.ItemEvent; |
| 45 |
|
import java.io.IOException; |
| 46 |
|
import java.util.List; |
| 47 |
|
|
| 48 |
|
import javax.swing.JButton; |
| 49 |
|
import javax.swing.JPanel; |
| 50 |
|
|
| 51 |
|
import org.testng.annotations.BeforeClass; |
| 52 |
|
import org.testng.annotations.BeforeMethod; |
| 53 |
|
import org.testng.annotations.Test; |
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
| 57 |
|
|
| 58 |
|
@author |
| 59 |
|
|
| 60 |
|
|
| |
|
| 99.7% |
Uncovered Elements: 1 (350) |
Complexity: 32 |
Complexity Density: 0.1 |
|
| 61 |
|
public class AnnotationChooserTest |
| 62 |
|
{ |
| 63 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 64 |
1 |
@BeforeClass(alwaysRun = true)... |
| 65 |
|
public void setUpJvOptionPane() |
| 66 |
|
{ |
| 67 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 68 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 69 |
|
} |
| 70 |
|
|
| 71 |
|
|
| 72 |
|
final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n" |
| 73 |
|
+ "TIETHKEAELVG-\n" |
| 74 |
|
+ ">FER_CAPAN Ferredoxin, chloroplast precursor\n" |
| 75 |
|
+ "TIETHKEAELVG-\n" |
| 76 |
|
+ ">FER1_SOLLC Ferredoxin-1, chloroplast precursor\n" |
| 77 |
|
+ "TIETHKEEELTA-\n" + ">Q93XJ9_SOLTU Ferredoxin I precursor\n" |
| 78 |
|
+ "TIETHKEEELTA-\n"; |
| 79 |
|
|
| 80 |
|
AnnotationChooser testee; |
| 81 |
|
|
| 82 |
|
AlignmentPanel parentPanel; |
| 83 |
|
|
| 84 |
|
AlignFrame af; |
| 85 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
| 86 |
17 |
@BeforeMethod(alwaysRun = true)... |
| 87 |
|
public void setUp() throws IOException |
| 88 |
|
{ |
| 89 |
17 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
| 90 |
|
|
| 91 |
17 |
Cache.applicationProperties.setProperty(Preferences.SORT_ANNOTATIONS, |
| 92 |
|
SequenceAnnotationOrder.NONE.name()); |
| 93 |
17 |
final String TRUE = Boolean.TRUE.toString(); |
| 94 |
17 |
Cache.applicationProperties.setProperty(Preferences.SHOW_AUTOCALC_ABOVE, |
| 95 |
|
TRUE); |
| 96 |
17 |
Cache.applicationProperties.setProperty("SHOW_QUALITY", TRUE); |
| 97 |
17 |
Cache.applicationProperties.setProperty("SHOW_CONSERVATION", TRUE); |
| 98 |
17 |
Cache.applicationProperties.setProperty("SHOW_IDENTITY", TRUE); |
| 99 |
|
|
| 100 |
17 |
AlignmentI al = new FormatAdapter().readFile(TEST_DATA, |
| 101 |
|
DataSourceType.PASTE, FileFormat.Fasta); |
| 102 |
17 |
af = new AlignFrame(al, 700, 500); |
| 103 |
17 |
parentPanel = new AlignmentPanel(af, af.getViewport()); |
| 104 |
17 |
addAnnotations(); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
| 110 |
|
|
| 111 |
|
|
| 112 |
|
|
| 113 |
|
|
| 114 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
|
| 115 |
17 |
private void addAnnotations()... |
| 116 |
|
{ |
| 117 |
17 |
Annotation an = new Annotation(2f); |
| 118 |
17 |
Annotation[] anns = new Annotation[] { an, an, an }; |
| 119 |
17 |
AlignmentAnnotation ann0 = new AlignmentAnnotation("IUPRED", "", anns); |
| 120 |
17 |
AlignmentAnnotation ann1 = new AlignmentAnnotation("Beauty", "", anns); |
| 121 |
17 |
AlignmentAnnotation ann2 = new AlignmentAnnotation("JMol", "", anns); |
| 122 |
17 |
AlignmentAnnotation ann3 = new AlignmentAnnotation("IUPRED", "", anns); |
| 123 |
17 |
AlignmentAnnotation ann4 = new AlignmentAnnotation("JMol", "", anns); |
| 124 |
17 |
SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray(); |
| 125 |
17 |
ann0.setSequenceRef(seqs[0]); |
| 126 |
17 |
ann2.setSequenceRef(seqs[3]); |
| 127 |
17 |
ann3.setSequenceRef(seqs[2]); |
| 128 |
17 |
ann4.setSequenceRef(seqs[1]); |
| 129 |
17 |
parentPanel.getAlignment().addAnnotation(ann0); |
| 130 |
17 |
parentPanel.getAlignment().addAnnotation(ann1); |
| 131 |
17 |
parentPanel.getAlignment().addAnnotation(ann2); |
| 132 |
17 |
parentPanel.getAlignment().addAnnotation(ann3); |
| 133 |
17 |
parentPanel.getAlignment().addAnnotation(ann4); |
| 134 |
|
} |
| 135 |
|
|
| 136 |
|
|
| 137 |
|
|
| 138 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
| 139 |
1 |
@Test(groups = { "Functional" })... |
| 140 |
|
public void testBuildActionButtonsPanel() |
| 141 |
|
{ |
| 142 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 143 |
1 |
JPanel jp = testee.buildActionButtonsPanel(); |
| 144 |
1 |
assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout); |
| 145 |
|
|
| 146 |
1 |
Component[] comps = jp.getComponents(); |
| 147 |
1 |
assertEquals("Not 2 action buttons", 2, comps.length); |
| 148 |
|
|
| 149 |
1 |
final Component jb1 = comps[0]; |
| 150 |
1 |
final Component jb2 = comps[1]; |
| 151 |
|
|
| 152 |
1 |
assertEquals("Not 'OK' button", MessageManager.getString("action.ok"), |
| 153 |
|
((JButton) jb1).getText()); |
| 154 |
1 |
assertEquals("Wrong button font", JvSwingUtils.getLabelFont(), |
| 155 |
|
jb1.getFont()); |
| 156 |
|
|
| 157 |
1 |
assertEquals("Not 'Cancel' button", |
| 158 |
|
MessageManager.getString("action.cancel"), |
| 159 |
|
((JButton) jb2).getText()); |
| 160 |
1 |
assertEquals("Wrong button font", JvSwingUtils.getLabelFont(), |
| 161 |
|
jb2.getFont()); |
| 162 |
|
} |
| 163 |
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
|
|
| 167 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 168 |
1 |
@Test(groups = { "Functional" })... |
| 169 |
|
public void testBuildApplyToOptionsPanel_withSelectionGroup() |
| 170 |
|
{ |
| 171 |
1 |
selectSequences(0, 2, 3); |
| 172 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 173 |
|
|
| 174 |
1 |
JPanel jp = testee.buildApplyToOptionsPanel(); |
| 175 |
1 |
Component[] comps = jp.getComponents(); |
| 176 |
1 |
assertEquals("Not 3 radio buttons", 3, comps.length); |
| 177 |
|
|
| 178 |
1 |
final Checkbox cb1 = (Checkbox) comps[0]; |
| 179 |
1 |
final Checkbox cb2 = (Checkbox) comps[1]; |
| 180 |
1 |
final Checkbox cb3 = (Checkbox) comps[2]; |
| 181 |
|
|
| 182 |
1 |
assertTrue("Not enabled", cb1.isEnabled()); |
| 183 |
1 |
assertTrue("Not enabled", cb2.isEnabled()); |
| 184 |
1 |
assertTrue("Not enabled", cb3.isEnabled()); |
| 185 |
1 |
assertEquals("Option not selected", cb2, |
| 186 |
|
cb2.getCheckboxGroup().getSelectedCheckbox()); |
| 187 |
|
|
| 188 |
|
|
| 189 |
1 |
assertTrue(testee.isApplyToSelectedSequences()); |
| 190 |
1 |
assertFalse(testee.isApplyToUnselectedSequences()); |
| 191 |
|
} |
| 192 |
|
|
| 193 |
|
|
| 194 |
|
|
| 195 |
|
|
| 196 |
|
|
| 197 |
|
@param |
| 198 |
|
@param |
| 199 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
|
| 200 |
12 |
private void selectSequences(int... selected)... |
| 201 |
|
{ |
| 202 |
12 |
SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray(); |
| 203 |
12 |
SequenceGroup sg = new SequenceGroup(); |
| 204 |
12 |
for (int i : selected) |
| 205 |
|
{ |
| 206 |
24 |
sg.addSequence(seqs[i], false); |
| 207 |
|
} |
| 208 |
12 |
parentPanel.av.setSelectionGroup(sg); |
| 209 |
|
} |
| 210 |
|
|
| 211 |
|
|
| 212 |
|
|
| 213 |
|
|
| 214 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 215 |
1 |
@Test(groups = { "Functional" })... |
| 216 |
|
public void testBuildApplyToOptionsPanel_noSelectionGroup() |
| 217 |
|
{ |
| 218 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 219 |
1 |
JPanel jp = testee.buildApplyToOptionsPanel(); |
| 220 |
1 |
verifyApplyToOptionsPanel_noSelectionGroup(jp); |
| 221 |
|
} |
| 222 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
|
| 223 |
2 |
protected void verifyApplyToOptionsPanel_noSelectionGroup(JPanel jp)... |
| 224 |
|
{ |
| 225 |
2 |
assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout); |
| 226 |
2 |
Component[] comps = jp.getComponents(); |
| 227 |
2 |
assertEquals("Not 3 radio buttons", 3, comps.length); |
| 228 |
|
|
| 229 |
2 |
final Checkbox cb1 = (Checkbox) comps[0]; |
| 230 |
2 |
final Checkbox cb2 = (Checkbox) comps[1]; |
| 231 |
2 |
final Checkbox cb3 = (Checkbox) comps[2]; |
| 232 |
|
|
| 233 |
2 |
assertTrue("Not enabled", cb1.isEnabled()); |
| 234 |
2 |
assertFalse("Enabled", cb2.isEnabled()); |
| 235 |
2 |
assertFalse("Enabled", cb3.isEnabled()); |
| 236 |
2 |
assertEquals("Not selected", cb1, |
| 237 |
|
cb1.getCheckboxGroup().getSelectedCheckbox()); |
| 238 |
|
|
| 239 |
|
|
| 240 |
2 |
assertTrue(testee.isApplyToSelectedSequences()); |
| 241 |
2 |
assertTrue(testee.isApplyToUnselectedSequences()); |
| 242 |
|
|
| 243 |
2 |
assertEquals("Wrong text", |
| 244 |
|
MessageManager.getString("label.all_sequences"), |
| 245 |
|
cb1.getLabel()); |
| 246 |
2 |
assertEquals("Wrong text", |
| 247 |
|
MessageManager.getString("label.selected_sequences"), |
| 248 |
|
cb2.getLabel()); |
| 249 |
2 |
assertEquals("Wrong text", |
| 250 |
|
MessageManager.getString("label.except_selected_sequences"), |
| 251 |
|
cb3.getLabel()); |
| 252 |
|
} |
| 253 |
|
|
| 254 |
|
|
| 255 |
|
|
| 256 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
| 257 |
1 |
@Test(groups = { "Functional" })... |
| 258 |
|
public void testBuildShowHidePanel() |
| 259 |
|
{ |
| 260 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 261 |
1 |
JPanel jp = testee.buildShowHidePanel(); |
| 262 |
1 |
verifyShowHidePanel(jp); |
| 263 |
|
|
| 264 |
|
} |
| 265 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
| 266 |
2 |
protected void verifyShowHidePanel(JPanel jp)... |
| 267 |
|
{ |
| 268 |
2 |
assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout); |
| 269 |
2 |
Component[] comps = jp.getComponents(); |
| 270 |
2 |
assertEquals("Not 2 radio buttons", 2, comps.length); |
| 271 |
|
|
| 272 |
2 |
final Checkbox cb1 = (Checkbox) comps[0]; |
| 273 |
2 |
final Checkbox cb2 = (Checkbox) comps[1]; |
| 274 |
|
|
| 275 |
2 |
assertTrue("Show not enabled", cb1.isEnabled()); |
| 276 |
2 |
assertTrue("Hide not enabled", cb2.isEnabled()); |
| 277 |
|
|
| 278 |
|
|
| 279 |
2 |
assertEquals("Not selected", cb2, |
| 280 |
|
cb2.getCheckboxGroup().getSelectedCheckbox()); |
| 281 |
|
|
| 282 |
2 |
assertTrue("Show is flagged", !testee.isShowSelected()); |
| 283 |
|
|
| 284 |
2 |
assertEquals("Wrong text", |
| 285 |
|
MessageManager.getString("label.show_selected_annotations"), |
| 286 |
|
cb1.getLabel()); |
| 287 |
2 |
assertEquals("Wrong text", |
| 288 |
|
MessageManager.getString("label.hide_selected_annotations"), |
| 289 |
|
cb2.getLabel()); |
| 290 |
|
} |
| 291 |
|
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 295 |
1 |
@Test(groups = { "Functional" })... |
| 296 |
|
public void testBuildShowHideOptionsPanel() |
| 297 |
|
{ |
| 298 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 299 |
1 |
JPanel jp = testee.buildShowHideOptionsPanel(); |
| 300 |
1 |
assertTrue("Wrong layout", jp.getLayout() instanceof BorderLayout); |
| 301 |
1 |
Component[] comps = jp.getComponents(); |
| 302 |
1 |
assertEquals("Not 2 sub-panels", 2, comps.length); |
| 303 |
|
|
| 304 |
1 |
verifyShowHidePanel((JPanel) comps[0]); |
| 305 |
1 |
verifyApplyToOptionsPanel_noSelectionGroup((JPanel) comps[1]); |
| 306 |
|
} |
| 307 |
|
|
| 308 |
|
|
| 309 |
|
|
| 310 |
|
|
| 311 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 312 |
1 |
@Test(groups = { "Functional" })... |
| 313 |
|
public void testGetAnnotationTypes() |
| 314 |
|
{ |
| 315 |
1 |
selectSequences(1); |
| 316 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 317 |
|
|
| 318 |
|
|
| 319 |
|
|
| 320 |
1 |
List<String> types = AnnotationChooser |
| 321 |
|
.getAnnotationTypes(parentPanel.getAlignment(), true); |
| 322 |
1 |
assertEquals("Not two annotation types", 2, types.size()); |
| 323 |
1 |
assertTrue("IUPRED missing", types.contains("IUPRED")); |
| 324 |
1 |
assertTrue("JMol missing", types.contains("JMol")); |
| 325 |
|
|
| 326 |
1 |
types = AnnotationChooser.getAnnotationTypes(parentPanel.getAlignment(), |
| 327 |
|
false); |
| 328 |
1 |
assertEquals("Not six annotation types", 7, types.size()); |
| 329 |
1 |
assertTrue("IUPRED missing", types.contains("IUPRED")); |
| 330 |
1 |
assertTrue("JMol missing", types.contains("JMol")); |
| 331 |
1 |
assertTrue("Beauty missing", types.contains("Beauty")); |
| 332 |
|
|
| 333 |
1 |
assertTrue("Consensus missing", types.contains("Consensus")); |
| 334 |
1 |
assertTrue("Quality missing", types.contains("Quality")); |
| 335 |
1 |
assertTrue("Conservation missing", types.contains("Conservation")); |
| 336 |
1 |
assertTrue("Occupancy missing", types.contains("Occupancy")); |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
|
| 340 |
|
|
| 341 |
|
|
| 342 |
|
|
| 343 |
|
|
| 344 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 345 |
1 |
@Test(groups = { "Functional" })... |
| 346 |
|
public void testSelectType_hideForAll() |
| 347 |
|
{ |
| 348 |
1 |
selectSequences(1, 2); |
| 349 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 350 |
1 |
final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1); |
| 351 |
1 |
setSelected(hideCheckbox, true); |
| 352 |
|
|
| 353 |
1 |
final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee, 1, |
| 354 |
|
1, 0); |
| 355 |
1 |
setSelected(allSequencesCheckbox, true); |
| 356 |
|
|
| 357 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 358 |
|
.getAlignmentAnnotation(); |
| 359 |
|
|
| 360 |
1 |
int autocalc = countAutocalc(anns); |
| 361 |
1 |
assertTrue(anns[autocalc + 2].visible); |
| 362 |
1 |
assertTrue(anns[autocalc + 4].visible); |
| 363 |
|
|
| 364 |
1 |
setSelected(getTypeCheckbox("JMol"), true); |
| 365 |
1 |
assertTrue(anns[0].visible); |
| 366 |
1 |
assertTrue(anns[1].visible); |
| 367 |
1 |
assertTrue(anns[2].visible); |
| 368 |
1 |
assertTrue(anns[3].visible); |
| 369 |
1 |
assertTrue(anns[4].visible); |
| 370 |
1 |
assertTrue(anns[5].visible); |
| 371 |
1 |
assertFalse(anns[6].visible); |
| 372 |
1 |
assertTrue(anns[7].visible); |
| 373 |
1 |
assertFalse(anns[8].visible); |
| 374 |
|
} |
| 375 |
|
|
| 376 |
|
|
| 377 |
|
|
| 378 |
|
|
| 379 |
|
|
| 380 |
|
|
| 381 |
|
|
| 382 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
1PASS
|
|
| 383 |
1 |
@Test(groups = { "Functional" })... |
| 384 |
|
public void testSelectType_hideForSelected() |
| 385 |
|
{ |
| 386 |
1 |
selectSequences(1, 2); |
| 387 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 388 |
1 |
final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1); |
| 389 |
1 |
setSelected(hideCheckbox, true); |
| 390 |
|
|
| 391 |
|
|
| 392 |
|
|
| 393 |
|
|
| 394 |
|
|
| 395 |
|
|
| 396 |
|
|
| 397 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 398 |
|
.getAlignmentAnnotation(); |
| 399 |
|
|
| 400 |
1 |
int autocalc = countAutocalc(anns); |
| 401 |
1 |
assertTrue(anns[autocalc + 4].visible); |
| 402 |
|
|
| 403 |
1 |
setSelected(getTypeCheckbox("JMol"), true); |
| 404 |
1 |
assertTrue(anns[0].visible); |
| 405 |
1 |
assertTrue(anns[1].visible); |
| 406 |
1 |
assertTrue(anns[2].visible); |
| 407 |
1 |
assertTrue(anns[3].visible); |
| 408 |
1 |
assertTrue(anns[4].visible); |
| 409 |
1 |
assertTrue(anns[5].visible); |
| 410 |
1 |
assertTrue(anns[6].visible); |
| 411 |
1 |
assertTrue(anns[7].visible); |
| 412 |
1 |
assertFalse(anns[8].visible); |
| 413 |
|
} |
| 414 |
|
|
| 415 |
|
|
| 416 |
|
|
| 417 |
|
|
| 418 |
|
|
| 419 |
|
|
| 420 |
|
|
| 421 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 422 |
1 |
@Test(groups = { "Functional" })... |
| 423 |
|
public void testDeselectType_hideForAll() |
| 424 |
|
{ |
| 425 |
1 |
selectSequences(1, 2); |
| 426 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 427 |
|
|
| 428 |
1 |
final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1); |
| 429 |
1 |
setSelected(hideCheckbox, true); |
| 430 |
|
|
| 431 |
1 |
final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee, 1, |
| 432 |
|
1, 0); |
| 433 |
1 |
setSelected(allSequencesCheckbox, true); |
| 434 |
|
|
| 435 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 436 |
|
.getAlignmentAnnotation(); |
| 437 |
|
|
| 438 |
1 |
final Checkbox typeCheckbox = getTypeCheckbox("JMol"); |
| 439 |
|
|
| 440 |
|
|
| 441 |
1 |
setSelected(typeCheckbox, true); |
| 442 |
1 |
int autocalc = countAutocalc(anns); |
| 443 |
1 |
assertFalse(anns[autocalc + 2].visible); |
| 444 |
1 |
assertFalse(anns[autocalc + 4].visible); |
| 445 |
|
|
| 446 |
|
|
| 447 |
1 |
setSelected(typeCheckbox, false); |
| 448 |
1 |
for (AlignmentAnnotation ann : anns) |
| 449 |
|
{ |
| 450 |
9 |
assertTrue(ann.visible); |
| 451 |
|
} |
| 452 |
|
} |
| 453 |
|
|
| 454 |
|
|
| 455 |
|
|
| 456 |
|
|
| 457 |
|
@param |
| 458 |
|
@return |
| 459 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 460 |
9 |
private int countAutocalc(AlignmentAnnotation[] anns)... |
| 461 |
|
{ |
| 462 |
9 |
int count = 0; |
| 463 |
9 |
for (AlignmentAnnotation ann : anns) |
| 464 |
|
{ |
| 465 |
81 |
if (ann.autoCalculated) |
| 466 |
|
{ |
| 467 |
36 |
count++; |
| 468 |
|
} |
| 469 |
|
} |
| 470 |
9 |
return count; |
| 471 |
|
} |
| 472 |
|
|
| 473 |
|
|
| 474 |
|
|
| 475 |
|
|
| 476 |
|
|
| 477 |
|
|
| 478 |
|
|
| 479 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 480 |
1 |
@Test(groups = { "Functional" })... |
| 481 |
|
public void testDeselectType_hideForSelected() |
| 482 |
|
{ |
| 483 |
1 |
selectSequences(1, 2); |
| 484 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 485 |
1 |
final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1); |
| 486 |
1 |
setSelected(hideCheckbox, true); |
| 487 |
|
|
| 488 |
|
|
| 489 |
|
|
| 490 |
|
|
| 491 |
|
|
| 492 |
|
|
| 493 |
|
|
| 494 |
1 |
setSelected(getTypeCheckbox("JMol"), true); |
| 495 |
1 |
setSelected(getTypeCheckbox("JMol"), false); |
| 496 |
|
|
| 497 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 498 |
|
.getAlignmentAnnotation(); |
| 499 |
1 |
assertTrue(anns[0].visible); |
| 500 |
1 |
assertTrue(anns[1].visible); |
| 501 |
1 |
assertTrue(anns[2].visible); |
| 502 |
1 |
assertTrue(anns[3].visible); |
| 503 |
1 |
assertTrue(anns[4].visible); |
| 504 |
1 |
assertTrue(anns[5].visible); |
| 505 |
1 |
assertTrue(anns[6].visible); |
| 506 |
1 |
assertTrue(anns[7].visible); |
| 507 |
|
} |
| 508 |
|
|
| 509 |
|
|
| 510 |
|
|
| 511 |
|
|
| 512 |
|
|
| 513 |
|
|
| 514 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 515 |
1 |
@Test(groups = { "Functional" })... |
| 516 |
|
public void testSelectType_showForAll() |
| 517 |
|
{ |
| 518 |
1 |
selectSequences(1, 2); |
| 519 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 520 |
1 |
final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0); |
| 521 |
1 |
final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1); |
| 522 |
|
|
| 523 |
1 |
final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee, 1, |
| 524 |
|
1, 0); |
| 525 |
|
|
| 526 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 527 |
|
.getAlignmentAnnotation(); |
| 528 |
|
|
| 529 |
|
|
| 530 |
1 |
setSelected(allSequencesCheckbox, true); |
| 531 |
1 |
setSelected(hideCheckbox, true); |
| 532 |
1 |
setSelected(getTypeCheckbox("JMol"), true); |
| 533 |
1 |
int autocalc = countAutocalc(anns); |
| 534 |
1 |
assertFalse(anns[autocalc + 2].visible); |
| 535 |
1 |
assertFalse(anns[autocalc + 4].visible); |
| 536 |
|
|
| 537 |
1 |
setSelected(showCheckbox, true); |
| 538 |
1 |
for (AlignmentAnnotation ann : anns) |
| 539 |
|
{ |
| 540 |
9 |
assertTrue(ann.visible); |
| 541 |
|
} |
| 542 |
|
} |
| 543 |
|
|
| 544 |
|
|
| 545 |
|
|
| 546 |
|
|
| 547 |
|
|
| 548 |
|
|
| 549 |
|
|
| 550 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1PASS
|
|
| 551 |
1 |
@Test(groups = { "Functional" })... |
| 552 |
|
public void testSelectType_showForSelected() |
| 553 |
|
{ |
| 554 |
|
|
| 555 |
1 |
selectSequences(1, 2); |
| 556 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 557 |
1 |
final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0); |
| 558 |
1 |
final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1); |
| 559 |
|
|
| 560 |
1 |
final Checkbox selectedSequencesCheckbox = (Checkbox) getComponent( |
| 561 |
|
testee, 1, 1, 1); |
| 562 |
|
|
| 563 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 564 |
|
.getAlignmentAnnotation(); |
| 565 |
|
|
| 566 |
|
|
| 567 |
1 |
setSelected(selectedSequencesCheckbox, true); |
| 568 |
1 |
setSelected(hideCheckbox, true); |
| 569 |
1 |
setSelected(getTypeCheckbox("JMol"), true); |
| 570 |
|
|
| 571 |
1 |
int autocalc = countAutocalc(anns); |
| 572 |
1 |
assertTrue(anns[autocalc + 2].visible); |
| 573 |
1 |
assertFalse(anns[autocalc + 4].visible); |
| 574 |
|
|
| 575 |
1 |
setSelected(showCheckbox, true); |
| 576 |
|
|
| 577 |
1 |
for (AlignmentAnnotation ann : anns) |
| 578 |
|
{ |
| 579 |
9 |
assertTrue(ann.visible); |
| 580 |
|
} |
| 581 |
|
} |
| 582 |
|
|
| 583 |
|
|
| 584 |
|
|
| 585 |
|
|
| 586 |
|
|
| 587 |
|
|
| 588 |
|
|
| 589 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 590 |
1 |
@Test(groups = { "Functional" })... |
| 591 |
|
public void testDeselectType_showForAll() |
| 592 |
|
{ |
| 593 |
1 |
selectSequences(1, 2); |
| 594 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 595 |
|
|
| 596 |
1 |
final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0); |
| 597 |
1 |
setSelected(showCheckbox, true); |
| 598 |
|
|
| 599 |
1 |
final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee, 1, |
| 600 |
|
1, 0); |
| 601 |
1 |
setSelected(allSequencesCheckbox, true); |
| 602 |
|
|
| 603 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 604 |
|
.getAlignmentAnnotation(); |
| 605 |
|
|
| 606 |
1 |
final Checkbox typeCheckbox = getTypeCheckbox("JMol"); |
| 607 |
|
|
| 608 |
1 |
setSelected(typeCheckbox, true); |
| 609 |
1 |
int autocalc = countAutocalc(anns); |
| 610 |
1 |
assertTrue(anns[autocalc + 2].visible); |
| 611 |
1 |
assertTrue(anns[autocalc + 4].visible); |
| 612 |
|
|
| 613 |
|
|
| 614 |
1 |
setSelected(typeCheckbox, false); |
| 615 |
1 |
assertTrue(anns[0].visible); |
| 616 |
1 |
assertTrue(anns[1].visible); |
| 617 |
1 |
assertTrue(anns[2].visible); |
| 618 |
1 |
assertTrue(anns[3].visible); |
| 619 |
1 |
assertTrue(anns[4].visible); |
| 620 |
1 |
assertTrue(anns[5].visible); |
| 621 |
1 |
assertFalse(anns[6].visible); |
| 622 |
1 |
assertTrue(anns[7].visible); |
| 623 |
1 |
assertFalse(anns[8].visible); |
| 624 |
|
} |
| 625 |
|
|
| 626 |
|
|
| 627 |
|
|
| 628 |
|
|
| 629 |
|
|
| 630 |
|
|
| 631 |
|
|
| 632 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 1 |
Complexity Density: 0.05 |
1PASS
|
|
| 633 |
1 |
@Test(groups = { "Functional" })... |
| 634 |
|
public void testDeselectType_showForSelected() |
| 635 |
|
{ |
| 636 |
1 |
selectSequences(1, 2); |
| 637 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 638 |
1 |
final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0); |
| 639 |
1 |
setSelected(showCheckbox, true); |
| 640 |
|
|
| 641 |
|
|
| 642 |
|
|
| 643 |
|
|
| 644 |
|
|
| 645 |
|
|
| 646 |
|
|
| 647 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 648 |
|
.getAlignmentAnnotation(); |
| 649 |
|
|
| 650 |
|
|
| 651 |
1 |
setSelected(getTypeCheckbox("JMol"), true); |
| 652 |
1 |
int autocalc = countAutocalc(anns); |
| 653 |
1 |
assertTrue(anns[autocalc + 2].visible); |
| 654 |
1 |
assertTrue(anns[autocalc + 4].visible); |
| 655 |
|
|
| 656 |
|
|
| 657 |
1 |
setSelected(getTypeCheckbox("JMol"), false); |
| 658 |
1 |
assertTrue(anns[0].visible); |
| 659 |
1 |
assertTrue(anns[1].visible); |
| 660 |
1 |
assertTrue(anns[2].visible); |
| 661 |
1 |
assertTrue(anns[3].visible); |
| 662 |
1 |
assertTrue(anns[4].visible); |
| 663 |
1 |
assertTrue(anns[5].visible); |
| 664 |
1 |
assertTrue(anns[6].visible); |
| 665 |
1 |
assertTrue(anns[7].visible); |
| 666 |
1 |
assertFalse(anns[8].visible); |
| 667 |
|
} |
| 668 |
|
|
| 669 |
|
|
| 670 |
|
|
| 671 |
|
|
| 672 |
|
@param |
| 673 |
|
@param |
| 674 |
|
@param |
| 675 |
|
@param |
| 676 |
|
@return |
| 677 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
| 678 |
19 |
public static Component getComponent(Container cont, int... positions)... |
| 679 |
|
{ |
| 680 |
19 |
Component comp = cont; |
| 681 |
19 |
for (int i : positions) |
| 682 |
|
{ |
| 683 |
57 |
comp = ((Container) comp).getComponent(i); |
| 684 |
|
} |
| 685 |
19 |
return comp; |
| 686 |
|
} |
| 687 |
|
|
| 688 |
|
|
| 689 |
|
|
| 690 |
|
|
| 691 |
|
@param |
| 692 |
|
@param |
| 693 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 694 |
33 |
protected void setSelected(Checkbox cb, boolean select)... |
| 695 |
|
{ |
| 696 |
|
|
| 697 |
33 |
cb.setState(select); |
| 698 |
|
|
| 699 |
33 |
cb.getItemListeners()[0].itemStateChanged( |
| 700 |
|
new ItemEvent(cb, ItemEvent.ITEM_STATE_CHANGED, cb, |
| 701 |
33 |
select ? ItemEvent.SELECTED : ItemEvent.DESELECTED)); |
| 702 |
|
} |
| 703 |
|
|
| 704 |
|
|
| 705 |
|
|
| 706 |
|
|
| 707 |
|
|
| 708 |
|
@return |
| 709 |
|
|
| |
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 2 |
Complexity Density: 0.33 |
|
| 710 |
12 |
private Checkbox getTypeCheckbox(String forLabel)... |
| 711 |
|
{ |
| 712 |
12 |
Component[] cbs = ((JPanel) testee.getComponent(0)).getComponents(); |
| 713 |
12 |
for (Component comp : cbs) |
| 714 |
|
{ |
| 715 |
23 |
final Checkbox cb = (Checkbox) comp; |
| 716 |
23 |
if (cb.getLabel().equals(forLabel)) |
| 717 |
|
{ |
| 718 |
12 |
return cb; |
| 719 |
|
} |
| 720 |
|
} |
| 721 |
0 |
return null; |
| 722 |
|
} |
| 723 |
|
|
| 724 |
|
|
| 725 |
|
|
| 726 |
|
|
| 727 |
|
|
| 728 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
| 729 |
1 |
@Test(groups = { "Functional" })... |
| 730 |
|
public void testIsInActionScope_selectedScope() |
| 731 |
|
{ |
| 732 |
|
|
| 733 |
1 |
selectSequences(1, 2); |
| 734 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 735 |
|
|
| 736 |
1 |
final Checkbox selectedSequencesCheckbox = (Checkbox) getComponent( |
| 737 |
|
testee, 1, 1, 1); |
| 738 |
1 |
setSelected(selectedSequencesCheckbox, true); |
| 739 |
|
|
| 740 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 741 |
|
.getAlignmentAnnotation(); |
| 742 |
1 |
int autocalc = countAutocalc(anns); |
| 743 |
1 |
assertFalse(testee.isInActionScope(anns[autocalc])); |
| 744 |
1 |
assertFalse(testee.isInActionScope(anns[autocalc + 1])); |
| 745 |
1 |
assertFalse(testee.isInActionScope(anns[autocalc + 2])); |
| 746 |
1 |
assertTrue(testee.isInActionScope(anns[autocalc + 3])); |
| 747 |
1 |
assertTrue(testee.isInActionScope(anns[autocalc + 4])); |
| 748 |
|
} |
| 749 |
|
|
| 750 |
|
|
| 751 |
|
|
| 752 |
|
|
| 753 |
|
|
| 754 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
1PASS
|
|
| 755 |
1 |
@Test(groups = { "Functional" })... |
| 756 |
|
public void testIsInActionScope_unselectedScope() |
| 757 |
|
{ |
| 758 |
|
|
| 759 |
1 |
selectSequences(1, 2); |
| 760 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 761 |
|
|
| 762 |
1 |
final Checkbox unselectedSequencesCheckbox = (Checkbox) getComponent( |
| 763 |
|
testee, 1, 1, 2); |
| 764 |
1 |
setSelected(unselectedSequencesCheckbox, true); |
| 765 |
|
|
| 766 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 767 |
|
.getAlignmentAnnotation(); |
| 768 |
1 |
int autocalc = countAutocalc(anns); |
| 769 |
1 |
assertTrue(testee.isInActionScope(anns[autocalc])); |
| 770 |
1 |
assertTrue(testee.isInActionScope(anns[autocalc + 1])); |
| 771 |
1 |
assertTrue(testee.isInActionScope(anns[autocalc + 2])); |
| 772 |
1 |
assertFalse(testee.isInActionScope(anns[autocalc + 3])); |
| 773 |
1 |
assertFalse(testee.isInActionScope(anns[autocalc + 4])); |
| 774 |
|
} |
| 775 |
|
|
| 776 |
|
|
| 777 |
|
|
| 778 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (26) |
Complexity: 3 |
Complexity Density: 0.14 |
1PASS
|
|
| 779 |
1 |
@Test(groups = { "Functional" })... |
| 780 |
|
public void testResetOriginalState() |
| 781 |
|
{ |
| 782 |
1 |
testee = new AnnotationChooser(parentPanel); |
| 783 |
|
|
| 784 |
1 |
AlignmentAnnotation[] anns = parentPanel.getAlignment() |
| 785 |
|
.getAlignmentAnnotation(); |
| 786 |
|
|
| 787 |
10 |
for (int i = 0; i < anns.length; i++) |
| 788 |
|
{ |
| 789 |
9 |
assertTrue(i + "'th sequence not visible", anns[i].visible); |
| 790 |
|
} |
| 791 |
|
|
| 792 |
|
|
| 793 |
|
|
| 794 |
|
|
| 795 |
1 |
final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1); |
| 796 |
1 |
setSelected(hideCheckbox, true); |
| 797 |
|
|
| 798 |
1 |
final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee, 1, |
| 799 |
|
1, 0); |
| 800 |
1 |
setSelected(allSequencesCheckbox, true); |
| 801 |
|
|
| 802 |
1 |
setSelected(getTypeCheckbox("JMol"), true); |
| 803 |
1 |
setSelected(getTypeCheckbox("IUPRED"), true); |
| 804 |
|
|
| 805 |
1 |
assertTrue(anns[0].visible); |
| 806 |
1 |
assertTrue(anns[1].visible); |
| 807 |
1 |
assertTrue(anns[2].visible); |
| 808 |
1 |
assertTrue(anns[3].visible); |
| 809 |
1 |
assertFalse(anns[4].visible); |
| 810 |
1 |
assertTrue(anns[5].visible); |
| 811 |
1 |
assertFalse(anns[6].visible); |
| 812 |
1 |
assertFalse(anns[7].visible); |
| 813 |
1 |
assertFalse(anns[8].visible); |
| 814 |
|
|
| 815 |
|
|
| 816 |
1 |
testee.resetOriginalState(); |
| 817 |
10 |
for (int i = 0; i < anns.length; i++) |
| 818 |
|
{ |
| 819 |
9 |
assertTrue(i + "'th sequence not visible", anns[i].visible); |
| 820 |
|
} |
| 821 |
|
} |
| 822 |
|
} |