3 import static org.testng.AssertJUnit.assertEquals;
4 import static org.testng.AssertJUnit.assertFalse;
5 import static org.testng.AssertJUnit.assertTrue;
7 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
8 import jalview.bin.Cache;
9 import jalview.datamodel.AlignmentAnnotation;
10 import jalview.datamodel.AlignmentI;
11 import jalview.datamodel.Annotation;
12 import jalview.datamodel.SequenceGroup;
13 import jalview.datamodel.SequenceI;
14 import jalview.io.AppletFormatAdapter;
15 import jalview.util.MessageManager;
17 import java.awt.BorderLayout;
18 import java.awt.Checkbox;
19 import java.awt.Component;
20 import java.awt.Container;
21 import java.awt.FlowLayout;
22 import java.awt.event.ItemEvent;
23 import java.io.IOException;
24 import java.util.List;
26 import javax.swing.JButton;
27 import javax.swing.JPanel;
29 import org.testng.annotations.BeforeMethod;
30 import org.testng.annotations.Test;
33 * Unit tests for AnnotationChooser
38 public class AnnotationChooserTest
40 // 4 sequences x 13 positions
41 final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n"
43 + ">FER_CAPAN Ferredoxin, chloroplast precursor\n"
45 + ">FER1_SOLLC Ferredoxin-1, chloroplast precursor\n"
46 + "TIETHKEEELTA-\n" + ">Q93XJ9_SOLTU Ferredoxin I precursor\n"
49 AnnotationChooser testee;
51 AlignmentPanel parentPanel;
55 @BeforeMethod(alwaysRun = true)
56 public void setUp() throws IOException
58 // pin down annotation sort order for test
59 Cache.applicationProperties.setProperty(Preferences.SORT_ANNOTATIONS,
60 SequenceAnnotationOrder.NONE.name());
61 final String True = Boolean.TRUE.toString();
62 Cache.applicationProperties.setProperty(
63 Preferences.SHOW_AUTOCALC_ABOVE, True);
64 Cache.applicationProperties.setProperty("SHOW_QUALITY", True);
65 Cache.applicationProperties.setProperty("SHOW_CONSERVATION", True);
66 Cache.applicationProperties.setProperty("SHOW_IDENTITY", True);
68 AlignmentI al = new jalview.io.FormatAdapter().readFile(TEST_DATA,
69 AppletFormatAdapter.PASTE, "FASTA");
70 af = new AlignFrame(al, 700, 500);
71 parentPanel = new AlignmentPanel(af, af.getViewport());
76 * Add 4 annotations, 3 of them sequence-specific.
79 * ann1 - for sequence 0 - label 'IUPRED'
80 * ann2 - not sequence related - label 'Beauty'
81 * ann3 - for sequence 3 - label 'JMol'
82 * ann4 - for sequence 2 - label 'IUPRED'
83 * ann5 - for sequence 1 - label 'JMol'
85 private void addAnnotations()
87 Annotation an = new Annotation(2f);
88 Annotation[] anns = new Annotation[] { an, an, an };
89 AlignmentAnnotation ann0 = new AlignmentAnnotation("IUPRED", "", anns);
90 AlignmentAnnotation ann1 = new AlignmentAnnotation("Beauty", "", anns);
91 AlignmentAnnotation ann2 = new AlignmentAnnotation("JMol", "", anns);
92 AlignmentAnnotation ann3 = new AlignmentAnnotation("IUPRED", "", anns);
93 AlignmentAnnotation ann4 = new AlignmentAnnotation("JMol", "", anns);
94 SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray();
95 ann0.setSequenceRef(seqs[0]);
96 ann2.setSequenceRef(seqs[3]);
97 ann3.setSequenceRef(seqs[2]);
98 ann4.setSequenceRef(seqs[1]);
99 parentPanel.getAlignment().addAnnotation(ann0);
100 parentPanel.getAlignment().addAnnotation(ann1);
101 parentPanel.getAlignment().addAnnotation(ann2);
102 parentPanel.getAlignment().addAnnotation(ann3);
103 parentPanel.getAlignment().addAnnotation(ann4);
107 * Test creation of panel with OK and Cancel buttons
109 @Test(groups = { "Functional" })
110 public void testBuildActionButtonsPanel()
112 testee = new AnnotationChooser(parentPanel);
113 JPanel jp = testee.buildActionButtonsPanel();
114 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
116 Component[] comps = jp.getComponents();
117 assertEquals("Not 2 action buttons", 2, comps.length);
119 final Component jb1 = comps[0];
120 final Component jb2 = comps[1];
122 assertEquals("Not 'OK' button", MessageManager.getString("action.ok"),
123 ((JButton) jb1).getText());
124 assertEquals("Wrong button font", JvSwingUtils.getLabelFont(),
127 assertEquals("Not 'Cancel' button",
128 MessageManager.getString("action.cancel"),
129 ((JButton) jb2).getText());
130 assertEquals("Wrong button font", JvSwingUtils.getLabelFont(),
135 * Test 'Apply to' has 3 radio buttons enabled, 'Selected Sequences' selected,
136 * when there is a current selection group.
138 @Test(groups = { "Functional" })
139 public void testBuildApplyToOptionsPanel_withSelectionGroup()
141 selectSequences(0, 2, 3);
142 testee = new AnnotationChooser(parentPanel);
144 JPanel jp = testee.buildApplyToOptionsPanel();
145 Component[] comps = jp.getComponents();
146 assertEquals("Not 3 radio buttons", 3, comps.length);
148 final Checkbox cb1 = (Checkbox) comps[0];
149 final Checkbox cb2 = (Checkbox) comps[1];
150 final Checkbox cb3 = (Checkbox) comps[2];
152 assertTrue("Not enabled", cb1.isEnabled());
153 assertTrue("Not enabled", cb2.isEnabled());
154 assertTrue("Not enabled", cb3.isEnabled());
155 assertEquals("Option not selected", cb2, cb2.getCheckboxGroup()
156 .getSelectedCheckbox());
158 // check state variables match checkbox selection
159 assertTrue(testee.isApplyToSelectedSequences());
160 assertFalse(testee.isApplyToUnselectedSequences());
164 * Add a sequence group to the alignment with the specified sequences (base 0)
170 private void selectSequences(int... selected)
172 SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray();
173 SequenceGroup sg = new SequenceGroup();
174 for (int i : selected)
176 sg.addSequence(seqs[i], false);
178 parentPanel.av.setSelectionGroup(sg);
182 * Test 'Apply to' has 1 radio button enabled, 'All Sequences' selected, when
183 * there is no current selection group.
185 @Test(groups = { "Functional" })
186 public void testBuildApplyToOptionsPanel_noSelectionGroup()
188 testee = new AnnotationChooser(parentPanel);
189 JPanel jp = testee.buildApplyToOptionsPanel();
190 verifyApplyToOptionsPanel_noSelectionGroup(jp);
193 protected void verifyApplyToOptionsPanel_noSelectionGroup(JPanel jp)
195 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
196 Component[] comps = jp.getComponents();
197 assertEquals("Not 3 radio buttons", 3, comps.length);
199 final Checkbox cb1 = (Checkbox) comps[0];
200 final Checkbox cb2 = (Checkbox) comps[1];
201 final Checkbox cb3 = (Checkbox) comps[2];
203 assertTrue("Not enabled", cb1.isEnabled());
204 assertFalse("Enabled", cb2.isEnabled());
205 assertFalse("Enabled", cb3.isEnabled());
206 assertEquals("Not selected", cb1, cb1.getCheckboxGroup()
207 .getSelectedCheckbox());
209 // check state variables match checkbox selection
210 assertTrue(testee.isApplyToSelectedSequences());
211 assertTrue(testee.isApplyToUnselectedSequences());
213 assertEquals("Wrong text",
214 MessageManager.getString("label.all_sequences"), cb1.getLabel());
215 assertEquals("Wrong text",
216 MessageManager.getString("label.selected_sequences"),
218 assertEquals("Wrong text",
219 MessageManager.getString("label.except_selected_sequences"),
224 * Test Show and Hide radio buttons created, with Hide initially selected.
226 @Test(groups = { "Functional" })
227 public void testBuildShowHidePanel()
229 testee = new AnnotationChooser(parentPanel);
230 JPanel jp = testee.buildShowHidePanel();
231 verifyShowHidePanel(jp);
235 protected void verifyShowHidePanel(JPanel jp)
237 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
238 Component[] comps = jp.getComponents();
239 assertEquals("Not 2 radio buttons", 2, comps.length);
241 final Checkbox cb1 = (Checkbox) comps[0];
242 final Checkbox cb2 = (Checkbox) comps[1];
244 assertTrue("Show not enabled", cb1.isEnabled());
245 assertTrue("Hide not enabled", cb2.isEnabled());
247 // Hide (button 2) selected; note this may change to none (null)
248 assertEquals("Not selected", cb2, cb2.getCheckboxGroup()
249 .getSelectedCheckbox());
251 assertTrue("Show is flagged", !testee.isShowSelected());
253 assertEquals("Wrong text",
254 MessageManager.getString("label.show_selected_annotations"),
256 assertEquals("Wrong text",
257 MessageManager.getString("label.hide_selected_annotations"),
262 * Test construction of panel containing two sub-panels
264 @Test(groups = { "Functional" })
265 public void testBuildShowHideOptionsPanel()
267 testee = new AnnotationChooser(parentPanel);
268 JPanel jp = testee.buildShowHideOptionsPanel();
269 assertTrue("Wrong layout", jp.getLayout() instanceof BorderLayout);
270 Component[] comps = jp.getComponents();
271 assertEquals("Not 2 sub-panels", 2, comps.length);
273 verifyShowHidePanel((JPanel) comps[0]);
274 verifyApplyToOptionsPanel_noSelectionGroup((JPanel) comps[1]);
278 * Test that annotation types are (uniquely) identified.
281 @Test(groups = { "Functional" })
282 public void testGetAnnotationTypes()
285 testee = new AnnotationChooser(parentPanel);
286 // selection group should make no difference to the result
287 // as all annotation types for the alignment are considered
289 List<String> types = AnnotationChooser.getAnnotationTypes(
290 parentPanel.getAlignment(), true);
291 assertEquals("Not two annotation types", 2, types.size());
292 assertTrue("IUPRED missing", types.contains("IUPRED"));
293 assertTrue("JMol missing", types.contains("JMol"));
295 types = AnnotationChooser.getAnnotationTypes(
296 parentPanel.getAlignment(), false);
297 assertEquals("Not six annotation types", 6, types.size());
298 assertTrue("IUPRED missing", types.contains("IUPRED"));
299 assertTrue("JMol missing", types.contains("JMol"));
300 assertTrue("Beauty missing", types.contains("Beauty"));
301 // These are added by viewmodel.AlignViewport.initAutoAnnotation():
302 assertTrue("Consensus missing", types.contains("Consensus"));
303 assertTrue("Quality missing", types.contains("Quality"));
304 assertTrue("Conservation missing", types.contains("Conservation"));
308 * Test result of selecting an annotation type, with 'Hide for all sequences'.
310 * We expect all annotations of that type to be set hidden. Other annotations
311 * should be left visible.
313 @Test(groups = { "Functional" })
314 public void testSelectType_hideForAll()
316 selectSequences(1, 2);
317 testee = new AnnotationChooser(parentPanel);
318 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
319 setSelected(hideCheckbox, true);
321 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
323 setSelected(allSequencesCheckbox, true);
325 AlignmentAnnotation[] anns = parentPanel.getAlignment()
326 .getAlignmentAnnotation();
328 assertTrue(anns[5].visible); // JMol for seq3
329 assertTrue(anns[7].visible); // JMol for seq1
331 setSelected(getTypeCheckbox("JMol"), true);
332 assertTrue(anns[0].visible); // Conservation
333 assertTrue(anns[1].visible); // Quality
334 assertTrue(anns[2].visible); // Consensus
335 assertTrue(anns[3].visible); // IUPred for seq0
336 assertTrue(anns[4].visible); // Beauty
337 assertFalse(anns[5].visible); // JMol for seq3 - not selected but hidden
338 assertTrue(anns[6].visible); // IUPRED for seq2
339 assertFalse(anns[7].visible); // JMol for seq1 - selected and hidden
343 * Test result of selecting an annotation type, with 'Hide for selected
346 * We expect the annotations of that type, linked to the sequence group, to be
347 * set hidden. Other annotations should be left visible.
349 @Test(groups = { "Functional" })
350 public void testSelectType_hideForSelected()
352 selectSequences(1, 2);
353 testee = new AnnotationChooser(parentPanel);
354 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
355 setSelected(hideCheckbox, true);
358 * Don't set the 'selected sequences' radio button since this would trigger
359 * an update, including unselected sequences / annotation types
361 // setSelected(getSelectedSequencesCheckbox());
363 AlignmentAnnotation[] anns = parentPanel.getAlignment()
364 .getAlignmentAnnotation();
366 assertTrue(anns[7].visible); // JMol for seq1
368 setSelected(getTypeCheckbox("JMol"), true);
369 assertTrue(anns[0].visible); // Conservation
370 assertTrue(anns[1].visible); // Quality
371 assertTrue(anns[2].visible); // Consensus
372 assertTrue(anns[3].visible); // IUPred for seq0
373 assertTrue(anns[4].visible); // Beauty
374 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
375 assertTrue(anns[6].visible); // IUPRED for seq2
376 assertFalse(anns[7].visible); // JMol for seq1 in selection group
380 * Test result of deselecting an annotation type, with 'Hide for all
383 * We expect all annotations of that type to be set visible. Other annotations
384 * should be left unchanged.
386 @Test(groups = { "Functional" })
387 public void testDeselectType_hideForAll()
389 selectSequences(1, 2);
390 testee = new AnnotationChooser(parentPanel);
392 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
393 setSelected(hideCheckbox, true);
395 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
397 setSelected(allSequencesCheckbox, true);
399 AlignmentAnnotation[] anns = parentPanel.getAlignment()
400 .getAlignmentAnnotation();
402 final Checkbox typeCheckbox = getTypeCheckbox("JMol");
404 // select JMol - all hidden
405 setSelected(typeCheckbox, true);
406 assertFalse(anns[5].visible); // JMol for seq3
407 assertFalse(anns[7].visible); // JMol for seq1
409 // deselect JMol - all unhidden
410 setSelected(typeCheckbox, false);
411 assertTrue(anns[0].visible); // Conservation
412 assertTrue(anns[1].visible); // Quality
413 assertTrue(anns[2].visible); // Consensus
414 assertTrue(anns[3].visible); // IUPred for seq0
415 assertTrue(anns[4].visible); // Beauty
416 assertTrue(anns[5].visible); // JMol for seq3
417 assertTrue(anns[6].visible); // IUPRED for seq2
418 assertTrue(anns[7].visible); // JMol for seq1
422 * Test result of deselecting an annotation type, with 'Hide for selected
425 * We expect the annotations of that type, linked to the sequence group, to be
426 * set visible. Other annotations should be left unchanged.
428 @Test(groups = { "Functional" })
429 public void testDeselectType_hideForSelected()
431 selectSequences(1, 2);
432 testee = new AnnotationChooser(parentPanel);
433 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
434 setSelected(hideCheckbox, true);
437 * Don't set the 'selected sequences' radio button since this would trigger
438 * an update, including unselected sequences / annotation types
440 // setSelected(getSelectedSequencesCheckbox());
442 setSelected(getTypeCheckbox("JMol"), true);
443 setSelected(getTypeCheckbox("JMol"), false);
445 AlignmentAnnotation[] anns = parentPanel.getAlignment()
446 .getAlignmentAnnotation();
447 assertTrue(anns[0].visible); // Conservation
448 assertTrue(anns[1].visible); // Quality
449 assertTrue(anns[2].visible); // Consensus
450 assertTrue(anns[3].visible); // IUPred for seq0
451 assertTrue(anns[4].visible); // Beauty
452 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
453 assertTrue(anns[6].visible); // IUPRED for seq2
454 assertTrue(anns[7].visible); // JMol for seq1 in selection group
458 * Test result of selecting an annotation type, with 'Show for all sequences'.
460 * We expect all annotations of that type to be set visible. Other annotations
461 * should be left unchanged
463 @Test(groups = { "Functional" })
464 public void testSelectType_showForAll()
466 selectSequences(1, 2);
467 testee = new AnnotationChooser(parentPanel);
468 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
469 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
471 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
474 AlignmentAnnotation[] anns = parentPanel.getAlignment()
475 .getAlignmentAnnotation();
477 // hide all JMol annotations
478 setSelected(allSequencesCheckbox, true);
479 setSelected(hideCheckbox, true);
480 setSelected(getTypeCheckbox("JMol"), true);
481 assertFalse(anns[5].visible); // JMol for seq3
482 assertFalse(anns[7].visible); // JMol for seq1
483 // ...now show them...
484 setSelected(showCheckbox, true);
485 assertTrue(anns[0].visible); // Conservation
486 assertTrue(anns[1].visible); // Quality
487 assertTrue(anns[2].visible); // Consensus
488 assertTrue(anns[3].visible); // IUPred for seq0
489 assertTrue(anns[4].visible); // Beauty
490 assertTrue(anns[5].visible); // JMol for seq3
491 assertTrue(anns[6].visible); // IUPRED for seq2
492 assertTrue(anns[7].visible); // JMol for seq1
496 * Test result of selecting an annotation type, with 'Show for selected
499 * We expect all annotations of that type, linked to the sequence group, to be
500 * set visible. Other annotations should be left unchanged
502 @Test(groups = { "Functional" })
503 public void testSelectType_showForSelected()
505 // sequences 1 and 2 have annotations IUPred and Jmol
506 selectSequences(1, 2);
507 testee = new AnnotationChooser(parentPanel);
508 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
509 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
511 final Checkbox selectedSequencesCheckbox = (Checkbox) getComponent(
514 AlignmentAnnotation[] anns = parentPanel.getAlignment()
515 .getAlignmentAnnotation();
517 // hide all JMol annotations in the selection region (== annotation 7)
518 setSelected(selectedSequencesCheckbox, true);
519 setSelected(hideCheckbox, true);
520 setSelected(getTypeCheckbox("JMol"), true);
522 assertTrue(anns[5].visible); // JMol for seq3
523 assertFalse(anns[7].visible); // JMol for seq1
524 // ...now show them...
525 setSelected(showCheckbox, true);
527 assertTrue(anns[0].visible); // Conservation
528 assertTrue(anns[1].visible); // Quality
529 assertTrue(anns[2].visible); // Consensus
530 assertTrue(anns[3].visible); // IUPred for seq0
531 assertTrue(anns[4].visible); // Beauty
532 assertTrue(anns[5].visible); // JMol for seq3
533 assertTrue(anns[6].visible); // IUPRED for seq2
534 assertTrue(anns[7].visible); // JMol for seq1
538 * Test result of deselecting an annotation type, with 'Show for all
541 * We expect all annotations of that type to be set hidden. Other annotations
542 * should be left unchanged.
544 @Test(groups = { "Functional" })
545 public void testDeselectType_showForAll()
547 selectSequences(1, 2);
548 testee = new AnnotationChooser(parentPanel);
550 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
551 setSelected(showCheckbox, true);
553 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
555 setSelected(allSequencesCheckbox, true);
557 AlignmentAnnotation[] anns = parentPanel.getAlignment()
558 .getAlignmentAnnotation();
560 final Checkbox typeCheckbox = getTypeCheckbox("JMol");
561 // select JMol - all shown
562 setSelected(typeCheckbox, true);
563 assertTrue(anns[5].visible); // JMol for seq3
564 assertTrue(anns[7].visible); // JMol for seq1
566 // deselect JMol - all hidden
567 setSelected(typeCheckbox, false);
568 assertTrue(anns[0].visible); // Conservation
569 assertTrue(anns[1].visible); // Quality
570 assertTrue(anns[2].visible); // Consensus
571 assertTrue(anns[3].visible); // IUPred for seq0
572 assertTrue(anns[4].visible); // Beauty
573 assertFalse(anns[5].visible); // JMol for seq3
574 assertTrue(anns[6].visible); // IUPRED for seq2
575 assertFalse(anns[7].visible); // JMol for seq1
579 * Test result of deselecting an annotation type, with 'Show for selected
582 * We expect the annotations of that type, linked to the sequence group, to be
583 * set hidden. Other annotations should be left unchanged.
585 @Test(groups = { "Functional" })
586 public void testDeselectType_showForSelected()
588 selectSequences(1, 2);
589 testee = new AnnotationChooser(parentPanel);
590 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
591 setSelected(showCheckbox, true);
594 * Don't set the 'selected sequences' radio button since this would trigger
595 * an update, including unselected sequences / annotation types
597 // setSelected(getSelectedSequencesCheckbox());
599 AlignmentAnnotation[] anns = parentPanel.getAlignment()
600 .getAlignmentAnnotation();
602 // select JMol - should remain visible
603 setSelected(getTypeCheckbox("JMol"), true);
604 assertTrue(anns[5].visible); // JMol for seq3
605 assertTrue(anns[7].visible); // JMol for seq1
607 // deselect JMol - should be hidden for selected sequences only
608 setSelected(getTypeCheckbox("JMol"), false);
609 assertTrue(anns[0].visible); // Conservation
610 assertTrue(anns[1].visible); // Quality
611 assertTrue(anns[2].visible); // Consensus
612 assertTrue(anns[3].visible); // IUPred for seq0
613 assertTrue(anns[4].visible); // Beauty
614 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
615 assertTrue(anns[6].visible); // IUPRED for seq2
616 assertFalse(anns[7].visible); // JMol for seq1 in selection group
620 * Helper method to drill down to a sub-component in a Container hierarchy.
628 public static Component getComponent(Container cont, int... positions)
630 Component comp = cont;
631 for (int i : positions)
633 comp = ((Container) comp).getComponent(i);
639 * Helper method to set or unset a checkbox and fire its action listener.
644 protected void setSelected(Checkbox cb, boolean select)
646 // TODO refactor to a test utility class
648 // have to manually fire the action listener
649 cb.getItemListeners()[0].itemStateChanged(new ItemEvent(cb,
650 ItemEvent.ITEM_STATE_CHANGED, cb, select ? ItemEvent.SELECTED
651 : ItemEvent.DESELECTED));
655 * Helper method to drill down to the 'Annotation type' checkbox with given
660 private Checkbox getTypeCheckbox(String forLabel)
662 Component[] cbs = ((JPanel) testee.getComponent(0)).getComponents();
663 for (Component comp : cbs)
665 final Checkbox cb = (Checkbox) comp;
666 if (cb.getLabel().equals(forLabel))
675 * Test isInActionScope for the case where the scope is selected sequences.
676 * Test cases include sequences in the selection group, and others not in the
679 @Test(groups = { "Functional" })
680 public void testIsInActionScope_selectedScope()
682 // sequences 1 and 2 have annotations 4 and 3 respectively
683 selectSequences(1, 2);
684 testee = new AnnotationChooser(parentPanel);
686 final Checkbox selectedSequencesCheckbox = (Checkbox) getComponent(
688 setSelected(selectedSequencesCheckbox, true);
690 AlignmentAnnotation[] anns = parentPanel.getAlignment()
691 .getAlignmentAnnotation();
692 // remember 3 annotations to skip (Conservation/Quality/Consensus)
693 assertFalse(testee.isInActionScope(anns[3]));
694 assertFalse(testee.isInActionScope(anns[4]));
695 assertFalse(testee.isInActionScope(anns[5]));
696 assertTrue(testee.isInActionScope(anns[6]));
697 assertTrue(testee.isInActionScope(anns[7]));
701 * Test isInActionScope for the case where the scope is unselected sequences.
702 * Test cases include sequences in the selection group, and others not in the
705 @Test(groups = { "Functional" })
706 public void testIsInActionScope_unselectedScope()
708 // sequences 1 and 2 have annotations 4 and 3 respectively
709 selectSequences(1, 2);
710 testee = new AnnotationChooser(parentPanel);
712 final Checkbox unselectedSequencesCheckbox = (Checkbox) getComponent(
714 setSelected(unselectedSequencesCheckbox, true);
716 AlignmentAnnotation[] anns = parentPanel.getAlignment()
717 .getAlignmentAnnotation();
718 // remember 3 annotations to skip (Conservation/Quality/Consensus)
719 assertTrue(testee.isInActionScope(anns[3]));
720 assertTrue(testee.isInActionScope(anns[4]));
721 assertTrue(testee.isInActionScope(anns[5]));
722 assertFalse(testee.isInActionScope(anns[6]));
723 assertFalse(testee.isInActionScope(anns[7]));
727 * Test that the reset method restores previous visibility flags.
729 @Test(groups = { "Functional" })
730 public void testResetOriginalState()
732 testee = new AnnotationChooser(parentPanel);
734 AlignmentAnnotation[] anns = parentPanel.getAlignment()
735 .getAlignmentAnnotation();
737 for (int i = 0; i < anns.length; i++)
739 assertTrue(i + "'th sequence not visible", anns[i].visible);
742 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
743 setSelected(hideCheckbox, true);
745 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
747 setSelected(allSequencesCheckbox, true);
749 setSelected(getTypeCheckbox("JMol"), true);
750 setSelected(getTypeCheckbox("IUPRED"), true);
752 assertTrue(anns[0].visible); // Conservation
753 assertTrue(anns[1].visible); // Quality
754 assertTrue(anns[2].visible); // Consensus
755 assertTrue(anns[3].visible); // Beauty (not seq-related)
756 assertFalse(anns[4].visible); // IUPRED
757 assertFalse(anns[5].visible); // JMol
758 assertFalse(anns[6].visible); // IUPRED
759 assertFalse(anns[7].visible); // JMol
761 // reset - should all be visible
762 testee.resetOriginalState();
763 for (int i = 0; i < anns.length; i++)
765 assertTrue(i + "'th sequence not visible", anns[i].visible);