3 import static org.testng.AssertJUnit.assertEquals;
4 import static org.testng.AssertJUnit.assertFalse;
5 import static org.testng.AssertJUnit.assertTrue;
6 import org.testng.annotations.Test;
7 import org.testng.annotations.BeforeMethod;
8 import java.awt.BorderLayout;
9 import java.awt.Checkbox;
10 import java.awt.Component;
11 import java.awt.Container;
12 import java.awt.FlowLayout;
13 import java.awt.event.ItemEvent;
14 import java.io.IOException;
15 import java.util.List;
17 import javax.swing.JButton;
18 import javax.swing.JPanel;
20 import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder;
21 import jalview.bin.Cache;
22 import jalview.datamodel.AlignmentAnnotation;
23 import jalview.datamodel.AlignmentI;
24 import jalview.datamodel.Annotation;
25 import jalview.datamodel.SequenceGroup;
26 import jalview.datamodel.SequenceI;
27 import jalview.io.AppletFormatAdapter;
28 import jalview.util.MessageManager;
31 * Unit tests for AnnotationChooser
36 public class AnnotationChooserTest
38 // 4 sequences x 13 positions
39 final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n"
41 + ">FER_CAPAN Ferredoxin, chloroplast precursor\n"
43 + ">FER1_SOLLC Ferredoxin-1, chloroplast precursor\n"
44 + "TIETHKEEELTA-\n" + ">Q93XJ9_SOLTU Ferredoxin I precursor\n"
47 AnnotationChooser testee;
49 AlignmentPanel parentPanel;
54 public void setUp() throws IOException
56 // pin down annotation sort order for test
57 Cache.applicationProperties.setProperty(Preferences.SORT_ANNOTATIONS,
58 SequenceAnnotationOrder.NONE.name());
59 final String True = Boolean.TRUE.toString();
60 Cache.applicationProperties.setProperty(
61 Preferences.SHOW_AUTOCALC_ABOVE, True);
62 Cache.applicationProperties.setProperty("SHOW_QUALITY", True);
63 Cache.applicationProperties.setProperty("SHOW_CONSERVATION", True);
64 Cache.applicationProperties.setProperty("SHOW_IDENTITY", True);
66 AlignmentI al = new jalview.io.FormatAdapter().readFile(TEST_DATA,
67 AppletFormatAdapter.PASTE, "FASTA");
68 af = new AlignFrame(al, 700, 500);
69 parentPanel = new AlignmentPanel(af, af.getViewport());
74 * Add 4 annotations, 3 of them sequence-specific.
77 * ann1 - for sequence 0 - label 'IUPRED'
78 * ann2 - not sequence related - label 'Beauty'
79 * ann3 - for sequence 3 - label 'JMol'
80 * ann4 - for sequence 2 - label 'IUPRED'
81 * ann5 - for sequence 1 - label 'JMol'
83 private void addAnnotations()
85 Annotation an = new Annotation(2f);
86 Annotation[] anns = new Annotation[]
88 AlignmentAnnotation ann0 = new AlignmentAnnotation("IUPRED", "", anns);
89 AlignmentAnnotation ann1 = new AlignmentAnnotation("Beauty", "", anns);
90 AlignmentAnnotation ann2 = new AlignmentAnnotation("JMol", "", anns);
91 AlignmentAnnotation ann3 = new AlignmentAnnotation("IUPRED", "", anns);
92 AlignmentAnnotation ann4 = new AlignmentAnnotation("JMol", "", anns);
93 SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray();
94 ann0.setSequenceRef(seqs[0]);
95 ann2.setSequenceRef(seqs[3]);
96 ann3.setSequenceRef(seqs[2]);
97 ann4.setSequenceRef(seqs[1]);
98 parentPanel.getAlignment().addAnnotation(ann0);
99 parentPanel.getAlignment().addAnnotation(ann1);
100 parentPanel.getAlignment().addAnnotation(ann2);
101 parentPanel.getAlignment().addAnnotation(ann3);
102 parentPanel.getAlignment().addAnnotation(ann4);
106 * Test creation of panel with OK and Cancel buttons
109 public void testBuildActionButtonsPanel()
111 testee = new AnnotationChooser(parentPanel);
112 JPanel jp = testee.buildActionButtonsPanel();
113 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
115 Component[] comps = jp.getComponents();
116 assertEquals("Not 2 action buttons", 2, comps.length);
118 final Component jb1 = comps[0];
119 final Component jb2 = comps[1];
121 assertEquals("Not 'OK' button", MessageManager.getString("action.ok"),
122 ((JButton) jb1).getText());
123 assertEquals("Wrong button font", JvSwingUtils.getLabelFont(),
126 assertEquals("Not 'Cancel' button",
127 MessageManager.getString("action.cancel"),
128 ((JButton) jb2).getText());
129 assertEquals("Wrong button font", JvSwingUtils.getLabelFont(),
134 * Test 'Apply to' has 3 radio buttons enabled, 'Selected Sequences' selected,
135 * when there is a current selection group.
138 public void testBuildApplyToOptionsPanel_withSelectionGroup()
140 selectSequences(0, 2, 3);
141 testee = new AnnotationChooser(parentPanel);
143 JPanel jp = testee.buildApplyToOptionsPanel();
144 Component[] comps = jp.getComponents();
145 assertEquals("Not 3 radio buttons", 3, comps.length);
147 final Checkbox cb1 = (Checkbox) comps[0];
148 final Checkbox cb2 = (Checkbox) comps[1];
149 final Checkbox cb3 = (Checkbox) comps[2];
151 assertTrue("Not enabled", cb1.isEnabled());
152 assertTrue("Not enabled", cb2.isEnabled());
153 assertTrue("Not enabled", cb3.isEnabled());
154 assertEquals("Option not selected", cb2, cb2.getCheckboxGroup()
155 .getSelectedCheckbox());
157 // check state variables match checkbox selection
158 assertTrue(testee.isApplyToSelectedSequences());
159 assertFalse(testee.isApplyToUnselectedSequences());
163 * Add a sequence group to the alignment with the specified sequences (base 0)
169 private void selectSequences(int... selected)
171 SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray();
172 SequenceGroup sg = new SequenceGroup();
173 for (int i : selected)
175 sg.addSequence(seqs[i], false);
177 parentPanel.av.setSelectionGroup(sg);
181 * Test 'Apply to' has 1 radio button enabled, 'All Sequences' selected, when
182 * there is no current selection group.
185 public void testBuildApplyToOptionsPanel_noSelectionGroup()
187 testee = new AnnotationChooser(parentPanel);
188 JPanel jp = testee.buildApplyToOptionsPanel();
189 verifyApplyToOptionsPanel_noSelectionGroup(jp);
192 protected void verifyApplyToOptionsPanel_noSelectionGroup(JPanel jp)
194 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
195 Component[] comps = jp.getComponents();
196 assertEquals("Not 3 radio buttons", 3, comps.length);
198 final Checkbox cb1 = (Checkbox) comps[0];
199 final Checkbox cb2 = (Checkbox) comps[1];
200 final Checkbox cb3 = (Checkbox) comps[2];
202 assertTrue("Not enabled", cb1.isEnabled());
203 assertFalse("Enabled", cb2.isEnabled());
204 assertFalse("Enabled", cb3.isEnabled());
205 assertEquals("Not selected", cb1, cb1.getCheckboxGroup()
206 .getSelectedCheckbox());
208 // check state variables match checkbox selection
209 assertTrue(testee.isApplyToSelectedSequences());
210 assertTrue(testee.isApplyToUnselectedSequences());
212 assertEquals("Wrong text",
213 MessageManager.getString("label.all_sequences"), cb1.getLabel());
214 assertEquals("Wrong text",
215 MessageManager.getString("label.selected_sequences"),
217 assertEquals("Wrong text",
218 MessageManager.getString("label.except_selected_sequences"),
223 * Test Show and Hide radio buttons created, with Hide initially selected.
226 public void testBuildShowHidePanel()
228 testee = new AnnotationChooser(parentPanel);
229 JPanel jp = testee.buildShowHidePanel();
230 verifyShowHidePanel(jp);
234 protected void verifyShowHidePanel(JPanel jp)
236 assertTrue("Wrong layout", jp.getLayout() instanceof FlowLayout);
237 Component[] comps = jp.getComponents();
238 assertEquals("Not 2 radio buttons", 2, comps.length);
240 final Checkbox cb1 = (Checkbox) comps[0];
241 final Checkbox cb2 = (Checkbox) comps[1];
243 assertTrue("Show not enabled", cb1.isEnabled());
244 assertTrue("Hide not enabled", cb2.isEnabled());
246 // Hide (button 2) selected; note this may change to none (null)
247 assertEquals("Not selected", cb2, cb2.getCheckboxGroup()
248 .getSelectedCheckbox());
250 assertTrue("Show is flagged", !testee.isShowSelected());
252 assertEquals("Wrong text",
253 MessageManager.getString("label.show_selected_annotations"),
255 assertEquals("Wrong text",
256 MessageManager.getString("label.hide_selected_annotations"),
261 * Test construction of panel containing two sub-panels
264 public void testBuildShowHideOptionsPanel()
266 testee = new AnnotationChooser(parentPanel);
267 JPanel jp = testee.buildShowHideOptionsPanel();
268 assertTrue("Wrong layout", jp.getLayout() instanceof BorderLayout);
269 Component[] comps = jp.getComponents();
270 assertEquals("Not 2 sub-panels", 2, comps.length);
272 verifyShowHidePanel((JPanel) comps[0]);
273 verifyApplyToOptionsPanel_noSelectionGroup((JPanel) comps[1]);
277 * Test that annotation types are (uniquely) identified.
281 public void testGetAnnotationTypes()
284 testee = new AnnotationChooser(parentPanel);
285 // selection group should make no difference to the result
286 // as all annotation types for the alignment are considered
288 List<String> types = AnnotationChooser.getAnnotationTypes(
289 parentPanel.getAlignment(), true);
290 assertEquals("Not two annotation types", 2, types.size());
291 assertTrue("IUPRED missing", types.contains("IUPRED"));
292 assertTrue("JMol missing", types.contains("JMol"));
294 types = AnnotationChooser.getAnnotationTypes(
295 parentPanel.getAlignment(), false);
296 assertEquals("Not six annotation types", 6, types.size());
297 assertTrue("IUPRED missing", types.contains("IUPRED"));
298 assertTrue("JMol missing", types.contains("JMol"));
299 assertTrue("Beauty missing", types.contains("Beauty"));
300 // These are added by viewmodel.AlignViewport.initAutoAnnotation():
301 assertTrue("Consensus missing", types.contains("Consensus"));
302 assertTrue("Quality missing", types.contains("Quality"));
303 assertTrue("Conservation missing", types.contains("Conservation"));
307 * Test result of selecting an annotation type, with 'Hide for all sequences'.
309 * We expect all annotations of that type to be set hidden. Other annotations
310 * should be left visible.
313 public void testSelectType_hideForAll()
315 selectSequences(1, 2);
316 testee = new AnnotationChooser(parentPanel);
317 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
318 setSelected(hideCheckbox, true);
320 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
322 setSelected(allSequencesCheckbox, true);
324 AlignmentAnnotation[] anns = parentPanel.getAlignment()
325 .getAlignmentAnnotation();
327 assertTrue(anns[5].visible); // JMol for seq3
328 assertTrue(anns[7].visible); // JMol for seq1
330 setSelected(getTypeCheckbox("JMol"), true);
331 assertTrue(anns[0].visible); // Conservation
332 assertTrue(anns[1].visible); // Quality
333 assertTrue(anns[2].visible); // Consensus
334 assertTrue(anns[3].visible); // IUPred for seq0
335 assertTrue(anns[4].visible); // Beauty
336 assertFalse(anns[5].visible); // JMol for seq3 - not selected but hidden
337 assertTrue(anns[6].visible); // IUPRED for seq2
338 assertFalse(anns[7].visible); // JMol for seq1 - selected and hidden
342 * Test result of selecting an annotation type, with 'Hide for selected
345 * We expect the annotations of that type, linked to the sequence group, to be
346 * set hidden. Other annotations should be left visible.
349 public void testSelectType_hideForSelected()
351 selectSequences(1, 2);
352 testee = new AnnotationChooser(parentPanel);
353 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
354 setSelected(hideCheckbox, true);
357 * Don't set the 'selected sequences' radio button since this would trigger
358 * an update, including unselected sequences / annotation types
360 // setSelected(getSelectedSequencesCheckbox());
362 AlignmentAnnotation[] anns = parentPanel.getAlignment()
363 .getAlignmentAnnotation();
365 assertTrue(anns[7].visible); // JMol for seq1
367 setSelected(getTypeCheckbox("JMol"), true);
368 assertTrue(anns[0].visible); // Conservation
369 assertTrue(anns[1].visible); // Quality
370 assertTrue(anns[2].visible); // Consensus
371 assertTrue(anns[3].visible); // IUPred for seq0
372 assertTrue(anns[4].visible); // Beauty
373 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
374 assertTrue(anns[6].visible); // IUPRED for seq2
375 assertFalse(anns[7].visible); // JMol for seq1 in selection group
379 * Test result of deselecting an annotation type, with 'Hide for all
382 * We expect all annotations of that type to be set visible. Other annotations
383 * should be left unchanged.
386 public void testDeselectType_hideForAll()
388 selectSequences(1, 2);
389 testee = new AnnotationChooser(parentPanel);
391 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
392 setSelected(hideCheckbox, true);
394 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
396 setSelected(allSequencesCheckbox, true);
398 AlignmentAnnotation[] anns = parentPanel.getAlignment()
399 .getAlignmentAnnotation();
401 final Checkbox typeCheckbox = getTypeCheckbox("JMol");
403 // select JMol - all hidden
404 setSelected(typeCheckbox, true);
405 assertFalse(anns[5].visible); // JMol for seq3
406 assertFalse(anns[7].visible); // JMol for seq1
408 // deselect JMol - all unhidden
409 setSelected(typeCheckbox, false);
410 assertTrue(anns[0].visible); // Conservation
411 assertTrue(anns[1].visible); // Quality
412 assertTrue(anns[2].visible); // Consensus
413 assertTrue(anns[3].visible); // IUPred for seq0
414 assertTrue(anns[4].visible); // Beauty
415 assertTrue(anns[5].visible); // JMol for seq3
416 assertTrue(anns[6].visible); // IUPRED for seq2
417 assertTrue(anns[7].visible); // JMol for seq1
421 * Test result of deselecting an annotation type, with 'Hide for selected
424 * We expect the annotations of that type, linked to the sequence group, to be
425 * set visible. Other annotations should be left unchanged.
428 public void testDeselectType_hideForSelected()
430 selectSequences(1, 2);
431 testee = new AnnotationChooser(parentPanel);
432 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
433 setSelected(hideCheckbox, true);
436 * Don't set the 'selected sequences' radio button since this would trigger
437 * an update, including unselected sequences / annotation types
439 // setSelected(getSelectedSequencesCheckbox());
441 setSelected(getTypeCheckbox("JMol"), true);
442 setSelected(getTypeCheckbox("JMol"), false);
444 AlignmentAnnotation[] anns = parentPanel.getAlignment()
445 .getAlignmentAnnotation();
446 assertTrue(anns[0].visible); // Conservation
447 assertTrue(anns[1].visible); // Quality
448 assertTrue(anns[2].visible); // Consensus
449 assertTrue(anns[3].visible); // IUPred for seq0
450 assertTrue(anns[4].visible); // Beauty
451 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
452 assertTrue(anns[6].visible); // IUPRED for seq2
453 assertTrue(anns[7].visible); // JMol for seq1 in selection group
457 * Test result of selecting an annotation type, with 'Show for all sequences'.
459 * We expect all annotations of that type to be set visible. Other annotations
460 * should be left unchanged
463 public void testSelectType_showForAll()
465 selectSequences(1, 2);
466 testee = new AnnotationChooser(parentPanel);
467 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
468 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
470 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
473 AlignmentAnnotation[] anns = parentPanel.getAlignment()
474 .getAlignmentAnnotation();
476 // hide all JMol annotations
477 setSelected(allSequencesCheckbox, true);
478 setSelected(hideCheckbox, true);
479 setSelected(getTypeCheckbox("JMol"), true);
480 assertFalse(anns[5].visible); // JMol for seq3
481 assertFalse(anns[7].visible); // JMol for seq1
482 // ...now show them...
483 setSelected(showCheckbox, true);
484 assertTrue(anns[0].visible); // Conservation
485 assertTrue(anns[1].visible); // Quality
486 assertTrue(anns[2].visible); // Consensus
487 assertTrue(anns[3].visible); // IUPred for seq0
488 assertTrue(anns[4].visible); // Beauty
489 assertTrue(anns[5].visible); // JMol for seq3
490 assertTrue(anns[6].visible); // IUPRED for seq2
491 assertTrue(anns[7].visible); // JMol for seq1
495 * Test result of selecting an annotation type, with 'Show for selected
498 * We expect all annotations of that type, linked to the sequence group, to be
499 * set visible. Other annotations should be left unchanged
502 public void testSelectType_showForSelected()
504 // sequences 1 and 2 have annotations IUPred and Jmol
505 selectSequences(1, 2);
506 testee = new AnnotationChooser(parentPanel);
507 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
508 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
510 final Checkbox selectedSequencesCheckbox = (Checkbox) getComponent(
513 AlignmentAnnotation[] anns = parentPanel.getAlignment()
514 .getAlignmentAnnotation();
516 // hide all JMol annotations in the selection region (== annotation 7)
517 setSelected(selectedSequencesCheckbox, true);
518 setSelected(hideCheckbox, true);
519 setSelected(getTypeCheckbox("JMol"), true);
521 assertTrue(anns[5].visible); // JMol for seq3
522 assertFalse(anns[7].visible); // JMol for seq1
523 // ...now show them...
524 setSelected(showCheckbox, true);
526 assertTrue(anns[0].visible); // Conservation
527 assertTrue(anns[1].visible); // Quality
528 assertTrue(anns[2].visible); // Consensus
529 assertTrue(anns[3].visible); // IUPred for seq0
530 assertTrue(anns[4].visible); // Beauty
531 assertTrue(anns[5].visible); // JMol for seq3
532 assertTrue(anns[6].visible); // IUPRED for seq2
533 assertTrue(anns[7].visible); // JMol for seq1
537 * Test result of deselecting an annotation type, with 'Show for all
540 * We expect all annotations of that type to be set hidden. Other annotations
541 * should be left unchanged.
544 public void testDeselectType_showForAll()
546 selectSequences(1, 2);
547 testee = new AnnotationChooser(parentPanel);
549 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
550 setSelected(showCheckbox, true);
552 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
554 setSelected(allSequencesCheckbox, true);
556 AlignmentAnnotation[] anns = parentPanel.getAlignment()
557 .getAlignmentAnnotation();
559 final Checkbox typeCheckbox = getTypeCheckbox("JMol");
560 // select JMol - all shown
561 setSelected(typeCheckbox, true);
562 assertTrue(anns[5].visible); // JMol for seq3
563 assertTrue(anns[7].visible); // JMol for seq1
565 // deselect JMol - all hidden
566 setSelected(typeCheckbox, false);
567 assertTrue(anns[0].visible); // Conservation
568 assertTrue(anns[1].visible); // Quality
569 assertTrue(anns[2].visible); // Consensus
570 assertTrue(anns[3].visible); // IUPred for seq0
571 assertTrue(anns[4].visible); // Beauty
572 assertFalse(anns[5].visible); // JMol for seq3
573 assertTrue(anns[6].visible); // IUPRED for seq2
574 assertFalse(anns[7].visible); // JMol for seq1
578 * Test result of deselecting an annotation type, with 'Show for selected
581 * We expect the annotations of that type, linked to the sequence group, to be
582 * set hidden. Other annotations should be left unchanged.
585 public void testDeselectType_showForSelected()
587 selectSequences(1, 2);
588 testee = new AnnotationChooser(parentPanel);
589 final Checkbox showCheckbox = (Checkbox) getComponent(testee, 1, 0, 0);
590 setSelected(showCheckbox, true);
593 * Don't set the 'selected sequences' radio button since this would trigger
594 * an update, including unselected sequences / annotation types
596 // setSelected(getSelectedSequencesCheckbox());
598 AlignmentAnnotation[] anns = parentPanel.getAlignment()
599 .getAlignmentAnnotation();
601 // select JMol - should remain visible
602 setSelected(getTypeCheckbox("JMol"), true);
603 assertTrue(anns[5].visible); // JMol for seq3
604 assertTrue(anns[7].visible); // JMol for seq1
606 // deselect JMol - should be hidden for selected sequences only
607 setSelected(getTypeCheckbox("JMol"), false);
608 assertTrue(anns[0].visible); // Conservation
609 assertTrue(anns[1].visible); // Quality
610 assertTrue(anns[2].visible); // Consensus
611 assertTrue(anns[3].visible); // IUPred for seq0
612 assertTrue(anns[4].visible); // Beauty
613 assertTrue(anns[5].visible); // JMol for seq3 not in selection group
614 assertTrue(anns[6].visible); // IUPRED for seq2
615 assertFalse(anns[7].visible); // JMol for seq1 in selection group
619 * Helper method to drill down to a sub-component in a Container hierarchy.
627 public static Component getComponent(Container cont, int... positions)
629 Component comp = cont;
630 for (int i : positions)
632 comp = ((Container) comp).getComponent(i);
638 * Helper method to set or unset a checkbox and fire its action listener.
643 protected void setSelected(Checkbox cb, boolean select)
645 // TODO refactor to a test utility class
647 // have to manually fire the action listener
648 cb.getItemListeners()[0].itemStateChanged(new ItemEvent(cb,
649 ItemEvent.ITEM_STATE_CHANGED, cb, select ? ItemEvent.SELECTED
650 : ItemEvent.DESELECTED));
654 * Helper method to drill down to the 'Annotation type' checkbox with given
659 private Checkbox getTypeCheckbox(String forLabel)
661 Component[] cbs = ((JPanel) testee.getComponent(0)).getComponents();
662 for (Component comp : cbs)
664 final Checkbox cb = (Checkbox) comp;
665 if (cb.getLabel().equals(forLabel))
674 * Test isInActionScope for the case where the scope is selected sequences.
675 * Test cases include sequences in the selection group, and others not in the
679 public void testIsInActionScope_selectedScope()
681 // sequences 1 and 2 have annotations 4 and 3 respectively
682 selectSequences(1, 2);
683 testee = new AnnotationChooser(parentPanel);
685 final Checkbox selectedSequencesCheckbox = (Checkbox) getComponent(
687 setSelected(selectedSequencesCheckbox, true);
689 AlignmentAnnotation[] anns = parentPanel.getAlignment()
690 .getAlignmentAnnotation();
691 // remember 3 annotations to skip (Conservation/Quality/Consensus)
692 assertFalse(testee.isInActionScope(anns[3]));
693 assertFalse(testee.isInActionScope(anns[4]));
694 assertFalse(testee.isInActionScope(anns[5]));
695 assertTrue(testee.isInActionScope(anns[6]));
696 assertTrue(testee.isInActionScope(anns[7]));
700 * Test isInActionScope for the case where the scope is unselected sequences.
701 * Test cases include sequences in the selection group, and others not in the
705 public void testIsInActionScope_unselectedScope()
707 // sequences 1 and 2 have annotations 4 and 3 respectively
708 selectSequences(1, 2);
709 testee = new AnnotationChooser(parentPanel);
711 final Checkbox unselectedSequencesCheckbox = (Checkbox) getComponent(
713 setSelected(unselectedSequencesCheckbox, true);
715 AlignmentAnnotation[] anns = parentPanel.getAlignment()
716 .getAlignmentAnnotation();
717 // remember 3 annotations to skip (Conservation/Quality/Consensus)
718 assertTrue(testee.isInActionScope(anns[3]));
719 assertTrue(testee.isInActionScope(anns[4]));
720 assertTrue(testee.isInActionScope(anns[5]));
721 assertFalse(testee.isInActionScope(anns[6]));
722 assertFalse(testee.isInActionScope(anns[7]));
726 * Test that the reset method restores previous visibility flags.
729 public void testResetOriginalState()
731 testee = new AnnotationChooser(parentPanel);
733 AlignmentAnnotation[] anns = parentPanel.getAlignment()
734 .getAlignmentAnnotation();
736 for (int i = 0; i < anns.length; i++)
738 assertTrue(i + "'th sequence not visible", anns[i].visible);
741 final Checkbox hideCheckbox = (Checkbox) getComponent(testee, 1, 0, 1);
742 setSelected(hideCheckbox, true);
744 final Checkbox allSequencesCheckbox = (Checkbox) getComponent(testee,
746 setSelected(allSequencesCheckbox, true);
748 setSelected(getTypeCheckbox("JMol"), true);
749 setSelected(getTypeCheckbox("IUPRED"), true);
751 assertTrue(anns[0].visible); // Conservation
752 assertTrue(anns[1].visible); // Quality
753 assertTrue(anns[2].visible); // Consensus
754 assertTrue(anns[3].visible); // Beauty (not seq-related)
755 assertFalse(anns[4].visible); // IUPRED
756 assertFalse(anns[5].visible); // JMol
757 assertFalse(anns[6].visible); // IUPRED
758 assertFalse(anns[7].visible); // JMol
760 // reset - should all be visible
761 testee.resetOriginalState();
762 for (int i = 0; i < anns.length; i++)
764 assertTrue(i + "'th sequence not visible", anns[i].visible);