JAL-147 unit test for hide/show sequences update ViewportRanges
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 6 Jul 2017 14:59:09 +0000 (15:59 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Thu, 6 Jul 2017 14:59:09 +0000 (15:59 +0100)
src/jalview/viewmodel/AlignmentViewport.java
test/jalview/gui/AlignViewportTest.java

index d3e502b..5a7a27f 100644 (file)
@@ -1441,7 +1441,6 @@ public abstract class AlignmentViewport implements AlignViewportI,
         setSequenceAnnotationsVisible(seq, true);
       }
 
-      // ranges.setStartSeq(startSeq);
       ranges.setStartEndSeq(startSeq, endSeq + tmp.size());
 
       firePropertyChange("alignment", null, alignment.getSequences());
index 346d74d..b2286e0 100644 (file)
@@ -46,6 +46,7 @@ import jalview.schemes.ColourSchemeI;
 import jalview.schemes.PIDColourScheme;
 import jalview.structure.StructureSelectionManager;
 import jalview.util.MapList;
+import jalview.viewmodel.ViewportRanges;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -469,4 +470,46 @@ public class AlignViewportTest
     SequenceI cons = testme.getConsensusSeq();
     assertEquals("A-C", cons.getSequenceAsString());
   }
+
+  @Test(groups = { "Functional" })
+  public void testHideRevealSequences()
+  {
+    ViewportRanges ranges = testee.getRanges();
+    assertEquals(3, al.getHeight());
+    assertEquals(0, ranges.getStartSeq());
+    assertEquals(2, ranges.getEndSeq());
+
+    /*
+     * hide first sequence
+     */
+    testee.hideSequence(new SequenceI[] { al.getSequenceAt(0) });
+    assertEquals(2, al.getHeight());
+    assertEquals(0, ranges.getStartSeq());
+    assertEquals(1, ranges.getEndSeq());
+
+    /*
+     * reveal hidden sequences above the first
+     */
+    testee.showSequence(0);
+    assertEquals(3, al.getHeight());
+    assertEquals(0, ranges.getStartSeq());
+    assertEquals(2, ranges.getEndSeq());
+
+    /*
+     * hide first and third sequences
+     */
+    testee.hideSequence(new SequenceI[] { al.getSequenceAt(0),
+        al.getSequenceAt(2) });
+    assertEquals(1, al.getHeight());
+    assertEquals(0, ranges.getStartSeq());
+    assertEquals(0, ranges.getEndSeq());
+
+    /*
+     * reveal all hidden sequences
+     */
+    testee.showAllHiddenSeqs();
+    assertEquals(3, al.getHeight());
+    assertEquals(0, ranges.getStartSeq());
+    assertEquals(2, ranges.getEndSeq());
+  }
 }